After upgrade to spring boot 3, liquibasebase throws error
liquibase.exception.UnexpectedLiquibaseException: java.io.FileNotFoundException: JAR entry db/scripts/dml/importstatus.sql not found
the correct path is db/changelog/scripts/dml/importstatus.sql, somehow "changelog" gets removed.
Other changeSets work fine, error only happens in sqlFile with property
<property name="script-dir" value="scripts/dml" dbms="postgresql"/>
<changeSet id="insert-import-status">
<sqlFile path="${script-dir}/importstatus.sql"
splitStatements="false"
stripComments="false"
encoding="utf8"
relativeToChangelogFile="true"
endDelimiter=";"/>
</changeSet>
I tried to use path without property, use "scripts/dml/importstatus.sql" but still got same error.
This is a bug in Liquibase 4.17: https://github.com/liquibase/liquibase/issues/3393
Unfortunately, the Spring Boot dependency management suggests 4.17.2 in the latest releases, as 4.17 was the latest minor release at the time when Spring Boot 3 went GA.
You can either downgrade to 4.16.2 or upgrade to 4.18.0. For example, by overriding the property liquibase.version in your build.
Related
I get the following error:
Flyway failed to initialize: none of the following migration scripts locations could be found:
- classpath:db/*/migrations/
This is what the directory structure looks like:
And this is what I've tried:
# examples, obviously I tried these independently from each other
spring:
flyway:
# these work:
locations: "classpath:db"
locations: "classpath:db/release_1.0/migrations/"
# these don't work: (I am getting the same error as shown above)
locations: "classpath:db/**/migrations/"
locations: "classpath:db/release*/migrations/"
locations: "classpath:db/*/migrations/"
But they should work according to this blogpost from version 6.4. (I don't see it documented that they have removed it)
I am using spring-boot-starter-parent 2.4.1, so it is Flyway 7.1.1.
Can anyone explain to me how to specify the migrations folder using a wildcard in Flyway and why is it not working?
As Flyway's location support has grown to support wildcards, cloud storage, etc., Spring Boot's ability to accurately check the locations has decreased as described in this issue. As a result, support for location checking was deprecated in Spring Boot 2.5 and, after the deprecation period, it will be removed entirely. In the meantime, you can switch it off by setting spring.flyway.check-location to false.
I am getting the following liquibase error when I run my Spring Boot application:
Specifying files by absolute path was removed in Liquibase 4.0. Please use a relative path or add '/' to the classpath parameter.
Here is the class path in application.yaml:
liquibase:
change-log: classpath:db/changelog/db-changelog-master.xml
I also tried:
liquibase:
change-log: classpath:/db/changelog/db-changelog-master.xml
Here is folder structure:
Changlog master:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<include file="db-changelog-1.0.xml"/>
</databaseChangeLog>
I got this issue when putting the changelog files outside the resources folder, but if I include them under resources/db/changelog, then it would work fine with setting the bellow config.
spring.liquibase.change-log=classpath:/db/changelog/changelog-master.xml
Tested under 4.6.2
This is still an open issue unfortunately. See 2281.
Looks like this was fixed in v4.4.3
As explained here
How the Liquibase classpath worked before version 4.0
Before version 4.0, one of the default locations Liquibase added to
the classpath was the root directory in your filesystem (/). The
change caused issues because of a machine-dependent changelog path,
such as /home/my-user/projects/liquibase/changelog.xml, found under
the / directory. This way, Liquibase uses the given path as part of
the changeset identifier stored in the DATABASECHANGELOG table, and
when you run Liquibase from
/home/other-user/projects/liquibase/changelog.xml, Liquibase sees it
as a different changelog and tries to rerun all the previously run
changesets.
To prevent identification issues from happening, a / was removed as a
default part of the classpath. How the Liquibase classpath works in
4.0 and later versions
Starting with Liquibase 4.0, the root directory (/) is no longer a
default part of the classpath because of the issue mentioned in the
previous section.
...
The message "Please use a relative path or add '/' to the classpath parameter." refers to the root directory '/', and does not mean to add a slash to the start of your classpath path. Afaik, classpath:x and classpath:/x are the same.
Also, the message appears when the master changelog is not found, for whatever reason, so also a typo can cause this message. It's only a hint telling you that it might not be found because the file is not on the classpath, because they removed the root directory from the classpath, but it could also not be found because you specified the wrong path (I just did that).
To configure it correctly, the master changelog must be on the Liquibase classpath. In Spring Boot, the Liquibase classpath is set to the application's classpath, i.e. you can use src/main/resources.
Tl;dr: When your file is src/main/resources/db/changelog/db.changelog-master.xml use
spring.liquibase.change-log=classpath:/db/changelog/db.changelog-master.xml
I don't know, whether there was or is a bug in regards to that with certain Liquibase versions, but that's how it's supposed to work, anyway.
Just try to remove "classpath:" from "change-log:" parameter.
Also try to check your pom.xml ("changeLogFile" tag in configuration):
there should not be a "${basedir}" before change log file path.
<changeLogFile>
/src/main/resources/liquibase/changelog.xml
</changeLogFile>
As soon as I updated my liquibase jar to 3.8.9 from 3.5.3 I am seeing all the debug logs in my different project logs. How come debug mode is enabled by just upgrading the liquibase jar?
Liquibase 3.8.9 has 3 additional dependencies than tha last version 3.5.3 i.e. slf4-api, jaxb-api and logback-classic. Did anyone else faced similar issue if yes whats the solution to disable the debug mode.
I believe there have been significant logging changes made since 3.5.3, you can update logging to your preference in your liquibase.properties file. Here's a reference:
https://docs.liquibase.com/concepts/advanced/loglevel.html
ex.
logLevel=off
A question has already been posted here at Spring-boot jersey maven failed to run war file and its author has found a work around to get the Spring-boot app to run, but it's still an annoying bug.
Basically, when running a Spring-boot app with a Jersey configuration using ResourceConfig's public final ResourceConfig packages(final String... packages) with java -jar command or using Unix style ./app.jar start the following exception occurs:
java.io.FileNotFoundException:/path/app-1.0-SNAPSHOT.war!/WEB-INF/classes (No such file or directory)
Caused by: org.glassfish.jersey.server.internal.scanning.ResourceFinderException:
This does not occur when the app is ran with mvn spring-boor:run.
Not using packages("com.company.app.rest") is a work around, but it's a pain not to be able to have Jersey scan a base package.
Is this listed as a bug by the Spring-boot team?
I think it is but for some reason nobody complained hard enough. Can you please share your issue on #3413?
I am getting weird errors on Heroku cedar using hibernate-memcached 1.3:
Caught CNFE decoding 438 bytes of data java.lang.ClassNotFoundException: org.hibernate.cache.entry.CacheEntry
Somehow hibernate-memcached 1.3 is failing to work with spymemcached 2.8.1 and up.
It does not matter if i explicitly list spymemcached 2.7.3 in my pom.xml or i set spymemcached scope as provided - i always get CNFE
I was able to replicate this issue locally when i upgraded to spymemcached 2.8.1
Thanks.
If you are using webapp-runner.jar to run your app, then yes, you're right: spymemcached class files are contained in the jar file to support caching of session data.
According to webapp-runner this is true for version 7.0.29.1 or newer.
The most recent version that does not contain spymemcached classes I was able to find, though, is 7.0.22.1.
I suspect that you can work around your problem by downgrading webapp-runner to version 7.0.22.1.
At least that worked for me when I ran into similar problems, getting exceptions like this:
org.springframework.beans.factory.CannotLoadBeanClassException:
Error loading class [net.spy.memcached.spring.MemcachedClientFactoryBean]
for bean with name 'memcachedClient' defined in class path resource [memcached-context.xml]:
problem with class file or dependent class;
nested exception is java.lang.NoClassDefFoundError: org/springframework/beans/factory/FactoryBean
These problems only occurred when I ran my war file with webapp-runner.jar. Running it from within Eclipse or with a local plain vanilla Tomcat 7 worked just fine.