“Unexpected error running Liquibase: Unknown Reason” liquibase 3.3.5 and grails war file

為{幸葍}努か 提交于 2019-12-23 03:34:12

问题


This is the command I am running:

java -jar /root/liquibase/liquibase.jar \
  --driver=com.mysql.jdbc.Driver \
  --logLevel=debug \
  --changeLogFile=migrations/changelog.xml \
  --classpath=/usr/share/tomcat7/lib/mysql.jar:/var/lib/tomcat7/webapps/myApp.war \
  --url="jdbc:mysql://127.0.0.1:3306/mydb" \
  --username=myuser \
  --password=mypass \
  --contexts=MYCONTEXT \
  update

this fails with the following unhelpful error message:

Unexpected error running Liquibase: Unknown Reason

SEVERE 9/9/15 2:23 PM: liquibase: Unknown Reason
java.lang.AbstractMethodError
        at liquibase.database.DatabaseFactory.register(DatabaseFactory.java:87)
        at liquibase.database.DatabaseFactory.<init>(DatabaseFactory.java:29)
        at liquibase.database.DatabaseFactory.getInstance(DatabaseFactory.java:40)
        at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:50)
        at liquibase.integration.commandline.Main.doMigration(Main.java:884)
        at liquibase.integration.commandline.Main.run(Main.java:175)
        at liquibase.integration.commandline.Main.main(Main.java:94)

I have no idea where to look. I have verified that the jars and wars are correct, i.e.

ls /root/liquibase/liquibase.jar
ls /usr/share/tomcat7/lib/mysql.jar
ls /var/lib/tomcat7/webapps/revolve.war

All list the corresponding file.

Any ideas?

the war exploded looks like this:

WEB-INF\classes\migrations\
   changelog.xml
   lots_of_other_changes.xml
WEB-INF\classes\migrations\sql
   lots of sql files

I have tired lots of variations, including:

      --changeLogFile=WEB-INF/classes/migrations/changelog.xml \

the changelogs work find if I run them on my local pc outside of a war file, although I do have to cd into the directory where the main changelog.xml file is first, otherwise it does not work.

The main changelog looks like this:

<databaseChangeLog
    :
    <include file="baseline.xml"/>
    <include file="something.xml"/>

and these included files have things like this:

<changeSet id="something" author="me">
    <comment>something</comment>
    <sqlFile path="sql//something//new_things.sql" />
</changeSet>

NOTE:

  1. using the grails in-application auto-updater feature with the data-migration 1.4.0 plug wont work, as it is hard coded to use liquibase version 2.0.5 which has major bugs.
  2. using liquibase 3.4+ is not currently an option due to incompatibility.
  3. If I try the command without including the war file location, I correctly get an error saying could not find the changelog file expected, and it creates the DATABASECHANGELOCK table in the db (so that side is ok)
  4. No matter what I change changeLogFile ot, it always gives this error, even something completely wrong.
  5. We dont want to go through the pain of generating diff sql, and running that sql.

I suspect the issue is to do with the relative paths of the includes in the change sets.

I also tried changing all the

<include file="something.xml"/> 

to

<include file="something.xml" relativeToChangelogFile="true" />

and

    <sqlFile path="sql//something//new_things.sql" />

to

    <sqlFile relativeToChangelogFile="true" path="sql//something//new_things.sql" />

But this made no difference - same error. I tried exploding the war and running it on the exploded files - this works, but is not what we want (as there is no way to explode the war on the production machines - they dont have the jar command, and if we deploy the war to live servers, without the DB changes first, the live system will fail)


回答1:


I don't know about Grails, but I'm immediately noticing those doubled-slashes in your paths. I would expect them to cause problems.

Are you perhaps thinking of the need to quote Windows-style backslashes? Where you see things like: C:\\path\\to\\file.dat.

But you don't need to do that for Unix-style slashes (or forward-slashes, if you will). (And if you did you'd still have to quote them with backslashes, like this: \/path\/to\/file.dat -- but don't do that.)




回答2:


I have the same situation: using LiquiBase with a Grails application. I had to fall back to liquibase-core-2.0.5.jar, which is embedded in the Grails User Library. I could not figure out how to exclude the jar. Unfortunately, this version of LiquiBase is considered very buggy.



来源:https://stackoverflow.com/questions/32479875/unexpected-error-running-liquibase-unknown-reason-liquibase-3-3-5-and-grails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!