Liquibase commandline: diff

Hi, colleagues. I have quistion regarding diff or diffChangeLog usage from liquibase commandline tool.

I have latest liquibase unzipped on my pc and I’ve put need drivers into lib folder.


So, here is my liquibase properties:

  1. driver=net.sourceforge.jtds.jdbc.Driver
  2. classpath=jtds-1.3.1.jar
  3. changeLogFile=…/my-service/src/main/resources/db/migration/my-changelog.xml
  4. url=jdbc:jtds:sqlserver://localhost:1433/sample
  5. username=sa
  6. password=sa
  7. referenceUrl=hibernate:spring:com.my.dao.entities
  8. referenceDriver=net.sourceforge.jtds.jdbc.Driver
  9. referenceUsername=sa
  10. referencePassword=sa
  11. includeSystemClasspath=true
  12. logLevel=DEBUG
And I have next error. 

  1. >java -jar liquibase.jar diffChangeLog
  2. DEBUG 11.02.14 16:04:liquibase: Connected to sa@jdbc:jtds:sqlserver://localhost:1433/sample
  3. DEBUG 11.02.14 16:04:liquibase: Setting auto commit to false from true
  4. Liquibase diffChangeLog Failed: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to hibernate:spring:com.my.dao.entities with driver net.sourceforge.jtds.jdbc.Driver.  Possibly the wrong driver for the given database URL
  5. SEVERE 11.02.14 16:04:liquibase: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to hibernate:spring:com.my.dao.entities with driver net.sourceforge.jtds.jdbc.Driver.  Possibly the wrong driver for the given database URL
  6. liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to hibernate:spring:com.my.dao.entities with driver net.sourceforge.jtds.jdbc.Driver.  Possibly the wrong driver for the given database URL
  7.         at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:61)
  8.         at liquibase.integration.commandline.Main.createReferenceDatabaseFromCommandParams(Main.java:1005)
  9.         at liquibase.integration.commandline.Main.doMigration(Main.java:804)
  10.         at liquibase.integration.commandline.Main.main(Main.java:133)
  11. Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to hibernate:spring:com.my.dao.entities with driver net.sourceforge.jtds.jdbc.Driver.  Possibly the wrong driver for the given database URL
  12.         at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:231)
  13.         at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:141)
  14.         at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:52)
  15.         ... 3 more
  16. Caused by: liquibase.exception.DatabaseException: Connection could not be created to hibernate:spring:com.my.dao.entities with driver net.sourceforge.jtds.jdbc.Driver.  Possibly the wrong driver for the given database URL
  17.         at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:226)
  18.         ... 5 more

The same happent also for

  1. referenceDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver

Does anybody have an idea?

Leave the referenceDriver off. There is a hibernate driver that liquibase will default to for a hibernate: url.


Nathan

Hi,


First thanks for this great framework and plugin!


I’m having a similar problem while running liquibase-hibernate from maven. I started with


hibernate:spring:my.package?dialect=org.hibernate.dialect.Oracle10gDialect


I had an error message saying :


[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:diff (

default-cli) on project bel-schema-migrate: Error setting up or running Liquibas

e: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot fin

d database driver: Driver class was not specified and could not be determined fr

om the url (hibernate:spring:my.package?dialect=org.hibernate.dialect

.Oracle10gDialect) -> [Help 1]


So I added the driver as follow :


hibernate:spring:my.package?dialect=org.hibernate.dialect.Oracle10gDialect

oracle.jdbc.OracleDriver


Which led to the same error as the one described by Apavlenko :


[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:diff (

default-cli) on project bel-schema-migrate: Error setting up or running Liquibas

e: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException:

 Connection could not be created to hibernate:spring:my.package?diale

ct=org.hibernate.dialect.Oracle10gDialect with driver oracle.jdbc.OracleDriver.

 Possibly the wrong driver for the given database URL -> [Help 1]


Can you suggest a workaround?


Thanks,


Martin




You shouldn’t include the referenceDriver block.


Nathan

Does it work with setting the driver to liquibase.ext.hibernate.database.connection.HibernateDriver ?  And/or is the liquibase-hibernate jar in your classpath?


Nathan

Hi,

When ommiting the referenceDriver block there is an error saying:


.Oracle10gDialect) -> [Help 1]

Hi,


Yes liquibase hibernate is in the path. 

I tried removing the dialect but it did not change anything.

java.lang.NullPointerException
at liquibase.executor.jvm.JdbcExecutor$QueryCallableStatementCallback.do
InCallableStatement(JdbcExecutor.java:363)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:80)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:116)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:127)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:135)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:146)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:141)
at liquibase.database.AbstractJdbcDatabase.getConnectionSchemaName(AbstractJdbcDatabase.java:341)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:324)
at liquibase.snapshot.jvm.SchemaSnapshotGenerator.snapshotObject(SchemaSnapshotGenerator.java:44)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:59)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:62)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:62)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:62)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:131)
at liquibase.snapshot.DatabaseSnapshot.(DatabaseSnapshot.java:36)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:129)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:122)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:110)
at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:84)
at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.performLiquibaseTask(LiquibaseDatabaseDiff.java:148)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:377)
at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

I pushed a change that may fix your problem. I’m planning on having an updated liquibase-hiberate release early next week.


I attached a zip file renamed as .txt with the newest liquibase-hibernate.jar if you wanted to try it before then.


Nathan

Hello,


Thank you for sharing the jar update in advance :slight_smile:


I changed my pom to use your snapshot as follow

om the url (hibernate:spring:ma.awb.ebk.bel.domain?dialect=org.hibernate.dialect.Oracle10gDialect) -> [Help 1]

Hi,


I’m trying to understand the problem by reading the source from github.


Looking at the repo [1], it seems line 66 mentionned in [2] can’t trigger a NPE.

https://github.com/liquibase/liquibase/blob/master/liquibase-core/src/main/java/liquibase/executor/jvm/JdbcExecutor.java