endrec
endrec

Reputation: 467

Liquibase Hibernate Java 8 support

I hope someone had the same problem before, and asking here is quicker than the trial and error.

I have a Java 8 project, where I am trying to use Liquibase, and generate my changelog from my Entities:

liquibase --changeLogFile=changeLog.yaml 
          --url=hibernate:spring:com.example.domain?dialect=org.hibernate.dialect.MySQL5InnoDBDialect 
          --logLevel=debug generateChangeLog

I got the following error:

SEVERE 11/04/15 09:55: liquibase: Failed to scan classpath for unlisted classes
liquibase.exception.DatabaseException: javax.persistence.PersistenceException: Failed to scan classpath for unlisted classes
...
Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [.../Example.class]; ...

I compiled my project using Java 7, and liquibase works fine.

Liquibase Version: 3.3.2
Liquibase Hibernate4.2 Version: 3.5

As liquibase is open source, I can try and rebuild it using Java 8, but I have no idea if it will help.

Upvotes: 4

Views: 1040

Answers (2)

endrec
endrec

Reputation: 467

Eventually I have figured it out, though it was not so easy.

As Zielu pointed out, the problem was with Spring version. Not in my own project though, but in liquibase-hibernate.

So the solution was:

  1. Download liquibase-hibernate source from github
  2. Update hibernate and spring dependecies
  3. Build liquibase-hibernate jar
  4. Copy this freshly built jar to the liquibase CLI lib folder
  5. In the liquibase CLI lib folder, update spring and hibernate libraries

Run liquibase as above.

Upvotes: 2

Zielu
Zielu

Reputation: 8562

The exception indicates that problem is in the class reader from Spring, are you using the recent Spring version? The recent spring works with all Java 6-8 so you should not have a problem if you upgrade the Spring.

Also, is your runtime Java 8 as well? You may have more than JVM installed, for example runtime is 7 but you use JDK8, you would be able to build your project using Java8 but of course it will not run in Java7 environment.

Upvotes: 2

Related Questions