“运行Liquibase的意外错误:未知原因” liquibase 3.3.5和grails war文件 [英] "Unexpected error running Liquibase: Unknown Reason" liquibase 3.3.5 and grails war file

查看:515
本文介绍了“运行Liquibase的意外错误:未知原因” liquibase 3.3.5和grails war文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我正在运行的命令:

  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 \
更新



这会失败,并显示以下无用的错误讯息:

 意外的错误运行Liquibase:未知原因

SEVERE 9/9/15 2:23 PM:liquibase:未知原因
java.lang.AbstractMethodError
at liquibase.database.DatabaseFactory .register(DatabaseFactory.java:87)
at liquibase.database.DatabaseFactory。< init>(DatabaseFactory.java:29)
at liquibase.database.DatabaseFactory.getInstan ce(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)

我不知道在哪里寻找。我已经证实,罐子和战争是正确的,即

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

全部列出相应的文件。



有什么想法? b
$ b

战争爆炸了看起来像这样:

  WEB-INF \classes\migrations\ 
changelog.xml
lots_of_other_changes.xml
WEB-INF \classes\migrations\sql
大量sql文件

我有很多变化,包括:

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

changelogs工作如果我在我的本地电脑上运行它们war文件,尽管我必须cd进入主要changelog.xml文件所在的目录,否则它不起作用。



主要更新日志看起来像l ike this:

 < databaseChangeLog 

< include file =baseline.xml/ >
< include file =something.xml/>

这些包含的文件有这样的内容:

 < changeSet id =somethingauthor =me> 
< / comment>东西< / comment>
< sqlFile path =sql // something // new_things.sql/>
< / changeSet>

注意:


  1. 在数据迁移1.4.0插件中使用grails in-application auto-updater功能将无法正常工作,因为它被硬编码为使用liquibase版本2.0.5,其中存在重大错误。

  2. 使用liquibase 3.4+目前不是一个选项,因为不兼容。

  3. 如果我在不包含war文件位置的情况下尝试命令,我会正确地得到一个错误,说找不到更改日志文件的预期,并且它在db中创建DATABASECHANGELOCK表(这样就可以了)

  4. 无论我更改changeLogFile ot,它总会给出这个错误,甚至完全错误。 / li>
  5. 我们不想经历生成diff sql的痛苦,并运行那个sql。

我怀疑问题是在变更集中包含包含的相对路径。



我也尝试更改所有的

 < include file =something.xml/> 

 < include file =something.xmlativeToChangelogFile =true/> 

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

 < sqlFile relativeToChangelogFile =truepath =sql // something // new_things.sql/> 

但是这并没有什么区别 - 同样的错误。我试图爆炸战争并在爆炸文件上运行它 - 这是有效的,但不是我们想要的(因为没有办法在生产机器上爆发战争 - 它们没有jar命令,并且如果我们部署战争在没有数据库更改的情况下,直播系统将失败)解决方案

我有同样的情况:使用LiquiBase与一个Grails应用程序。我必须回到嵌入在Grails用户库中的 liquibase-core-2.0.5.jar 。我无法弄清楚如何排除罐子。不幸的是,这个版本的LiquiBase被认为是非常麻烦的。

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)

解决方案

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.

这篇关于“运行Liquibase的意外错误:未知原因” liquibase 3.3.5和grails war文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆