Java – liquibase hibernate plug-in does not work

As stated herein( https://github.com/liquibase/liquibase-hibernate/issues/74 )I encountered a problem making the liquibase hibernate extension work properly I think I've finished all the settings, but it seems that I've been having strange problems I think I missed something simple, but I think I've followed all the instructions provided

I am using liquibase 3.3 2,Hibernate 4.3. 0.Final,java 1.7. 0_ 71 and liquibase-hibernate 4-3.5 jar. My classpath environment variable is empty, but the liquibase shell script will add something When I interact with the normal liquibase command, I start with $liquibase_ The extension without extension is deleted from the home / lib / directory, and it works normally I output the restart command with debug to provide more information

$echo $CLASSPATH


$java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01,mixed mode)

$liquibase --version
Liquibase Version: 3.3.2

$liquibase diffChangeLog
//The below is the stuff liquibase is adding to my classpath
.:/c/repos/ServeDirtyLibsInJava/liquibaseLib/liquibase.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/liquibase-hibernate4-3.5.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/snakeyaml-1.13.jar
WARNING 1/19/15 12:42 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateEjb3Database as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 1/19/15 12:42 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateSpringDatabase as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 1/19/15 12:42 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateClassicDatabase as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
DEBUG 1/19/15 10:20 AM: liquibase: Connected to root@localhost@jdbc:MysqL://localhost:3306/dirtylibs
DEBUG 1/19/15 10:20 AM: liquibase: Setting auto commit to false from true
Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and Could not be determined from the url (hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MysqL5Dialect)

SEVERE 1/19/15 10:20 AM: liquibase: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and Could not be determined from the url (hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MysqL5Dialect)
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and Could not be determined from the url (hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialec
t.MysqL5Dialect)
        at liquibase.integration.commandline.CommandLineUtils.createDatabaSEObject(CommandLineUtils.java:69)
        at liquibase.integration.commandline.Main.createReferenceDatabaseFromCommandParams(Main.java:1169)
        at liquibase.integration.commandline.Main.doMigration(Main.java:936)
        at liquibase.integration.commandline.Main.run(Main.java:175)
        at liquibase.integration.commandline.Main.main(Main.java:94)
Caused by: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and Could not be determined from the url (hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MysqL5Dialect)
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:239)
        at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:143)
        at liquibase.integration.commandline.CommandLineUtils.createDatabaSEObject(CommandLineUtils.java:50)
        ... 4 more
Caused by: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and Could not be determined from the url (hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MysqL5Dialect)
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:191)
        ... 6 more

My liquibase Properties file

driver=com.MysqL.jdbc.Driver
classpath=mysql-connector-java-5.1.6.jar
url=jdbc:MysqL://localhost:3306/dirtylibs
username=root
password=password
changeLogFile=changelog.xml
#referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
referenceUrl=hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MysqL5Dialect
referenceUsername=root
referencePassword=password

If I uncomment my referencedriver, I will get this Is there anything I miss here? I thought I had all the necessary dependencies, and I wasn't sure if this was some manifestation of an earlier problem where the extension couldn't load the content correctly

$liquibase diffChangeLog
WARNING 1/19/15 12:49 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateEjb3Database as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 1/19/15 12:49 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateSpringDatabase as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 1/19/15 12:49 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateClassicDatabase as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 1/19/15 12:49 AM: liquibase: Can not use class liquibase.ext.hibernate.snapshot.SequenceSnapshotGenerator as a Liquibase service because org.hibernate.id.factory.IdentifierGeneratorFactory is not in the classpath
WARNING 1/19/15 12:49 AM: liquibase: Can not use class liquibase.ext.hibernate.snapshot.TableSnapshotGenerator as a Liquibase service because org.hibernate.id.factory.IdentifierGeneratorFactory is not in the classpath
Unexpected error running Liquibase: org.hibernate.sql.Alias
SEVERE 1/19/15 10:22 AM: liquibase: org.hibernate.sql.Alias
java.lang.NoClassDefFoundError: org/hibernate/sql/Alias
        at liquibase.ext.hibernate.snapshot.PrimaryKeySnapshotGenerator.<clinit>(PrimaryKeySnapshotGenerator.java:27)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at liquibase.snapshot.SnapshotGeneratorFactory.<init>(SnapshotGeneratorFactory.java:29)
        at liquibase.snapshot.SnapshotGeneratorFactory.getInstance(SnapshotGeneratorFactory.java:43)
        at liquibase.snapshot.SnapshotControl.addType(SnapshotControl.java:95)
        at liquibase.snapshot.SnapshotControl.setTypes(SnapshotControl.java:88)
        at liquibase.snapshot.SnapshotControl.<init>(SnapshotControl.java:25)
        at liquibase.command.DiffCommand.createReferenceSnapshot(DiffCommand.java:185)
        at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:140)
        at liquibase.command.DifftochangeLogCommand.run(DifftochangeLogCommand.java:51)
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
        at liquibase.integration.commandline.CommandLineUtils.doDifftochangeLog(CommandLineUtils.java:121)
        at liquibase.integration.commandline.Main.doMigration(Main.java:936)
        at liquibase.integration.commandline.Main.run(Main.java:175)
        at liquibase.integration.commandline.Main.main(Main.java:94)
Caused by: java.lang.ClassNotFoundException: org.hibernate.sql.Alias
        at java.net.urlclassloader$1.run(urlclassloader.java:366)
        at java.net.urlclassloader$1.run(urlclassloader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.urlclassloader.findClass(urlclassloader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 18 more

After adding hibernate jar to the liquibase / lib folder (which is really wrong), the error becomes this I tried to revert to the old version of the plug-in (while demoting liquibase), but it didn't help

$liquibase --logLevel=DEBUG diffChangeLog
.:/c/repos/ServeDirtyLibsInJava/liquibaseLib/liquibase.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/hibernate-core-4.3.0.Final.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/liquibase-hibernate4-3.5.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/snakeyaml-1.13.jar
WARNING 1/19/15 10:38 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateSpringDatabase as a Liquibase service because org.springframework.beans.factory.support.BeanDeFinitionRegistry is not in the classpath
DEBUG 1/19/15 10:38 AM: liquibase: Connected to root@localhost@jdbc:MysqL://localhost:3306/dirtylibs
DEBUG 1/19/15 10:38 AM: liquibase: Setting auto commit to false from true
WARNING 1/19/15 10:38 AM: liquibase: UnkNown database: Hibernate
DEBUG 1/19/15 10:38 AM: liquibase: Connected to null@hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MysqL5Dialect
DEBUG 1/19/15 10:38 AM: liquibase: Not adjusting the auto commit mode; it is already false
INFO 1/19/15 10:38 AM: liquibase: Error getting default schema
java.lang.NullPointerException
        at liquibase.executor.jvm.JdbcExecutor$QueryCallableStatementCallback.doInCallableStatement(JdbcExecutor.java:383)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:96)
        at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:132)
        at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:143)
        at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:151)
        at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:166)
        at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:161)
        at liquibase.database.AbstractJdbcDatabase.getConnectionSchemaName(AbstractJdbcDatabase.java:318)
        at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:301)
        at liquibase.CatalogAndSchema.customize(CatalogAndSchema.java:132)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:116)
        at liquibase.command.DiffCommand.createReferenceSnapshot(DiffCommand.java:190)
        at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:140)
        at liquibase.command.DifftochangeLogCommand.run(DifftochangeLogCommand.java:51)
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
        at liquibase.integration.commandline.CommandLineUtils.doDifftochangeLog(CommandLineUtils.java:121)
        at liquibase.integration.commandline.Main.doMigration(Main.java:936)
        at liquibase.integration.commandline.Main.run(Main.java:175)
        at liquibase.integration.commandline.Main.main(Main.java:94)
DEBUG 1/19/15 10:38 AM: liquibase: Computed checksum for 1421681927678 as b60efdd1567f2fd4e5407a8d157cb0b6
Unexpected error running Liquibase: java.lang.NullPointerException

SEVERE 1/19/15 10:38 AM: liquibase: java.lang.NullPointerException
liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at liquibase.integration.commandline.CommandLineUtils.doDifftochangeLog(CommandLineUtils.java:123)
        at liquibase.integration.commandline.Main.doMigration(Main.java:936)
        at liquibase.integration.commandline.Main.run(Main.java:175)
        at liquibase.integration.commandline.Main.main(Main.java:94)
Caused by: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
        at liquibase.integration.commandline.CommandLineUtils.doDifftochangeLog(CommandLineUtils.java:121)
        ... 3 more
Caused by: java.lang.NullPointerException
        at liquibase.snapshot.jvm.CatalogSnapshotGenerator.getDatabaseCatalogNames(CatalogSnapshotGenerator.java:82)
        at liquibase.snapshot.jvm.CatalogSnapshotGenerator.snapshotObject(CatalogSnapshotGenerator.java:41)
        at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60)
        at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:163)
        at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:55)
        at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:37)
        at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:25)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:119)
        at liquibase.command.DiffCommand.createReferenceSnapshot(DiffCommand.java:190)
        at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:140)
        at liquibase.command.DifftochangeLogCommand.run(DifftochangeLogCommand.java:51)
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
        ... 4 more

Solution

I do this by adding these jars to my classpath It's very chaotic and has no good record

>Download the source code of the correct plug-in project found here( https://github.com/liquibase/liquibase-hibernate/releases ), in my case, it is liquibase-hibernate 4-3.5. > Run MVN dependencies: copy dependencies This dumps them to / target / dependency / Copy all these jars and put them into library_ Home / lib directory. > I'm using gradle, so I use custom tasks to copy all dependencies If you are using maven, you can use the same steps in 2 of your project to get all depdates I copied these libraries from the output directory to library_ Home / lib directory

task copyToLib(type: Copy) {
    into "$buildDir/output/libs"
    from configurations.runtime
}

>I will also correct hibernate-liquibase-4.3 5. Jar into liquibase_ Home / lib directory

This gives me all the dependencies my Plug - in needs

It's a nasty mess ball, but what can you do:(

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>