JEE+WildFly启动时Liquibase报ChangeLogParseException:变更日志不存在
Let's work through this Liquibase ChangeLogParseException you're facing in your JEE + WildFly setup. The error makes it clear Liquibase can't locate your db-changelog.xml file, even though you've confirmed it's in the WAR and tested different path variations. Let's break down the fixes:
Error Log
09:41:40,602 ERROR [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0021: Deploy of deployment "bets.war" was rolled back with the following failure message: { "WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./bets" => "java.lang.RuntimeException: java.lang.RuntimeException: liquibase.exception.ChangeLogParseException: :classpath/WEB-INF/db-changelog.xml does not exist Caused by: java.lang.RuntimeException: java.lang.RuntimeException: liquibase.exception.ChangeLogParseException: :classpath/WEB-INF/db-changelog.xml does not exist Caused by: java.lang.RuntimeException: liquibase.exception.ChangeLogParseException: :classpath/WEB-INF/db-changelog.xml does not exist Caused by: liquibase.exception.ChangeLogParseException: :classpath/WEB-INF/db-changelog.xml does not exist"},
Current web.xml Configuration
<!-- liquibase auto startup --> <context-param> <param-name>liquibase.changelog</param-name> <param-value>:classpath/WEB-INF/db-changelog.xml</param-value> </context-param> <context-param> <param-name>liquibase.datasource</param-name> <param-value>java:jboss/datasources/BetsDS</param-value> </context-param> <context-param> <param-name>liquibase.onerror.fail</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>liquibase.contexts</param-name> <param-value>production</param-value> </context-param> <listener> <listener-class>liquibase.integration.servlet.LiquibaseServletListener</listener-class> </listener>
Root Cause Analysis
The first issue jumps out in the error message: the path :classpath/WEB-INF/db-changelog.xml has a leading colon before classpath. Liquibase expects classpath references to follow the format classpath:/path/to/file—the misplaced colon is breaking path parsing entirely.
Fixes to Implement
Correct the Classpath Prefix Format
Update yourliquibase.changelogparameter to use the standard classpath prefix syntax (remove the leading colon and add a slash afterclasspath:):<context-param> <param-name>liquibase.changelog</param-name> <param-value>classpath:/WEB-INF/db-changelog.xml</param-value> </context-param>This tells Liquibase to look for the file within the web app's classpath, which includes the
WEB-INFdirectory by default.Try the Servlet Context Path
If the classpath approach still fails, reference the file directly using the servlet context path (no classpath prefix needed):<context-param> <param-name>liquibase.changelog</param-name> <param-value>/WEB-INF/db-changelog.xml</param-value> </context-param>The
LiquibaseServletListenershould resolve this path using the web application'sServletContextwithout issues.Validate the WAR Package Structure
Even if you think the file is in place, extract your WAR to double-check the exact structure. Ensuredb-changelog.xmlis directly underWEB-INF/(not nested in a subfolder). The correct structure should look like:bets.war/ ├── WEB-INF/ │ ├── db-changelog.xml │ ├── web.xml │ └── classes/ └── ...Test a Classpath Alternative
As a quick test, movedb-changelog.xmltoWEB-INF/classes/and update the path toclasspath:/db-changelog.xml. This bypasses any edge cases withWEB-INFpath resolution in WildFly's classloader.Check Version Compatibility
Ensure your Liquibase version is compatible with your WildFly release. Older Liquibase versions may have path parsing bugs that don't play well with newer WildFly classloading rules.
内容的提问来源于stack exchange,提问作者Bartosz Gniado

