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>
Related
I know that liquibase will create a databasechangelog to check if one change set has been applied. But if i let the app to run it automatically, the FILENAME column will store the relative path of the changelog file. But if I run mvn liquibase:status, it said my change set had not been applied, the cause is that in liquibase.properties file I defined the path of the changelog as absolute path (i.e changeLogFile=src/main/resources/db/changelog/db-changeLog-master.xml) while for spring boot app automatic migration the path was defined as relative path (spring.liquibase.change-log=classpath:db/changelog/db-changeLog-master.xml) in application.properties file and "db/changelog/db-changeLog-master.xml" was stored in the database. If you do it manually (by running mvn liquibase:update), "src/main/resources/db/changelog/db-changeLog-master.xml" would be stored instead.
How could I solve this problem? Since I wanna have control over the migration (i.e. do the migration manually) or check the status of migration in development environment.
after I changed the property: changeLogFile=/db/changelog/db-changeLog-master.xml, in liquibase.properties, mvn command works as expected: now liquibase consider the path of my changelog to be "db/changelog/db-changeLog-master.xml"
Summary/Question
I've rolled onto a project that uses ehcache. The project is maven enabled and when I run mvn clean install from cli all ends well.
The project can also be opened in NetBeans and everything displays properly, however when I open the project in eclipse, I'm seeing some errors related to ehcache. In NetBeans the spring-cache.xml is located under a "Web Pages" folder. This made me think that the eclipse project may not be recognized as a dynamic web project, however following the directions here: https://www.mkyong.com/java/how-to-convert-java-project-to-web-project-in-eclipse/ I was able to verify that the project is indeed setup to support Dynamic Web Module, Java and JavaScript.
I also opened the project in IntelliJ and also did not see any issues with the spring-cache.xml.
I also didn't find documentation related to this version of ehcache on http://www.ehcache.org/documentation/ but the fact that things work in NetBeans, IntelliJ and via mvn clean install make me think its my eclipse setup. Thoughts?
More Details:
The errors I see in eclipse are:
Multiple annotations found at this line:
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'ehcache:annotation-driven'.
- schema_reference.4: Failed to read schema document 'http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring-1.1.xsd, because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
And
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'ehcache:config'.
My maven dependency looks like:
<dependency>
<groupId>com.googlecode.ehcache-spring-annotations</groupId>
<artifactId>ehcache-spring-annotations</artifactId>
<version>1.2.0</version>
</dependency>
Which matches what it should be, based on: https://mvnrepository.com/artifact/com.googlecode.ehcache-spring-annotations/ehcache-spring-annotations/1.2.0
My spring-cache.xml file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd">
<ehcache:annotation-driven />
<ehcache:config cache-manager="cacheManager">
<ehcache:evict-expired-elements interval="60" />
</ehcache:config>
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="${ehcache.config.location}"/>
</bean>
</beans>
Looks like current versions of NetBeans and IntelliJ aren't as strict on checking things as eclipse is. :) The following is what I found out.
From ehcache with Spring. google code xsd file not found I found out that the top error was related to the fact that the xsd is no longer hosted at the url provided.
Doing some googles, I found a reference to the version on github at: https://raw.githubusercontent.com/agentgt/ehcache-spring-annotations/master/core/src/main/resources/com/googlecode/ehcache/annotations/ehcache-spring-1.2.xsd by changing my bottom xsi schemalocation to the above url, it resolved the issue in eclipse.
The stack overflow questions referenced, also provides a link to the google code archive of: https://code.google.com/archive/p/ehcache-spring-annotations/source/default/source
If you download the zip, you can then find the offical xsd in the zip at: /schema/ehcache-spring/ehcache-spring-1.2.xsd (it also has ehcache-spring-1.0.xsd and ehcache-spring1.1.xsd in case anyone else has issues with even earlier versions).
I found a way to reference the local schema file here: How to reference a local XML Schema file correctly?
I'm going to post a question on how to reference it from a relative path of the project, as we have both windows and mac developers on this project. If this is of use to you, the details will be here: How to Reference Local XSD File By Relative Path
Summary of issue:
xsi-schemaLocation reference:
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd
results in validation-issues in eclipse, on commandline maven there are no issues.
replacing the ref with:
https://raw.githubusercontent.com/agentgt/ehcache-spring-annotations/master/core/src/main/resources/com/googlecode/ehcache/annotations/ehcache-spring-1.1.xsd
solves issue in eclipse. In maven the saxparser will complain however if you 're not connected to internet.
By putting a proxy ref :
-Dhttp.proxyHost=[proxyhost] -Dhttp.proxyPort=[proxyport] -Dhttps.proxyHost=[proxyhost] -Dhttps.proxyPort=[proxyport]
the maven build succeeds....
I investigated this difference in behaviour:
in the ehcache-spring jar, ehcache-spring-annotations-1.1.2.jar,
a META-INF/spring.schemas file is present.
Content of that file:
http\://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.0.xsd=com/googlecode/ehcache/annotations/ehcache-spring-1.0.xsd
http\://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd=com/googlecode/ehcache/annotations/ehcache-spring-1.1.xsd
cmdline maven uses this content (and finds the xsd in the jar).
eclipse does not.
Solution I used:
go to eclipse preferences,
XML -> XML Catalog and add a new user entry:
Location: https://raw.githubusercontent.com/agentgt/ehcache-spring-annotations/master/core/src/main/resources/com/googlecode/ehcache/annotations/ehcache-spring-1.1.xsd
Key type: Public id
Key: http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd
Alternative web adress: https://raw.githubusercontent.com/agentgt/ehcache-spring-annotations/master/core/src/main/resources/com/googlecode/ehcache/annotations/ehcache-spring-1.1.xsd
Re-validating spring context files solved issues in my eclipse workspace.
I like this solution better because it is a shortcoming of eclipse which i solve with an eclipse-specific solution.
I’ve succeed to externalize my spring-boot configuration file (application.properties) in a config folder when I run my spring-boot application as a unix service with the help of the official spring documentation https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
I have also some i18n messages.properties files in my src/main/resources that I would like to externalize in the same config folder but I failed to do it. I’ve tried a lot of things, like playing with spring.messages.basename but unfortunately, it doesn’t work.
I’m using the latest version of spring-boot, and use auto configure mode with the default i18n properties name messages.
What am I missing??? thanks for your help.
Just a few notes:
classpath:message - will always lookup embeded message_xxx files
classpath:/message and classpath:message are equivalent
file:message - will lookup jar's external current directory e.g. ./message_en.properties <- this is what you want
file:/message - you have to put your message files to root "/" to make it work
use notation file:config/message if you need to put in config folder together with your
./config/application.properties
I think you need a leading slash.
Try: spring.messages.basename=classpath:/config/messages
I think, resource bundle is default to classpath. So there's no need to append it. just go straight to your folder location from classpath.
Try this: **assuming your config is inside static folder
spring.messages.basename=static/config/messages
On my Oracle weblogic 12 installation I have deployed an .ear (built with maven). All is OK except when I go to wls-cat and check Classloader Tree I get entries such as:
D:\Oracle\Middleware\Oracle_Home\user_projects\domains\liferayportal\servers\AdminServer\tmp\_WL_user\mywebapp\nsio4q\APP-INF\lib\lib\antlr-2.7.6.jar
and
D:\Oracle\Middleware\Oracle_Home\user_projects\domains\liferayportal\servers\AdminServer\tmp\_WL_user\mywebapp\5ohvco\war\WEB-INF\lib\..\..\lib\
I have no \lib\lib folder and neither do \lib...\...\lib
What can be the cause? What should I check in my POMs? Thank you.
This is not related to your pom.xml
WLS expands the war file, but copy the files in different places, therefor It doesn't recreate a directory structure (ie: OC4J does it).
Therefore, WLS-CAT is telling where (psychically) is retrieving a particular class (from antlr jar file in your case).
I am working to implement RSS feed using the spring integration as mentioned in the article http://comdynamics.net/blog/295/spring-integration-rss-feed-reader/. However, when I run the application I am getting the following error:
Could not find fetcher.properties on classpath
Can you point me in the right direction?
Can you verify that you have the folder that contains this property file in the classpath of the project? You would have to look at .classpath file to verify this.
Ideally you would want to keep this file in a config folder and must be added to the classpath just like your source folder.
create an empty file named fetcher.properties on classpath. You don't have to add any entry to it.That will solve the problem