Issue (Maybe) in Liquibase-Maven-Plugin :2.0.0

Hi,

I tied using the liquibase maven plugin (with intellij) for generating diff between database Schema and the hibernate mapping files in the application. I struggled hard to get past the error “Could not Fine hibernate.cfg.xml” File.

I checked that the file was in the class path and Maven-Liquibase-Plugin was able to see it in its class-loaders classpath. (i  debugged and verified in org.liquibase.maven.plugins.LiquibaseDatabaseDiff getMavenArtifactClassLoader method). But the resource was not visible to the hibernate environment.

Hibernate finds the resource using its org.hibernate.util.ConfigHelper which checks for this resource in current Thread’s context class loader , ConfigHelper.class’s class loader and finally thru system classLoader but none of these loaders were able to find the resource.

To fix this i tried setting the mavenArtifactClassLoader as current Thread’s contextClassLoader in org.liquibase.maven.plugins.LiquibaseDatabaseDiff

Line:97            cl = getMavenArtifactClassLoader();
Line:98            Thread.currentThread().setContextClassLoader(cl);

This fixed my problem.

Please can you suggest if there was any other better way i could have resolved this ? Can we use this fix in the maven-liquibase-plugin project ?

Thanks

I’m not sure what all happens with maven classloaders, but I think your change will be fine.  I added it to the class for the next 2.0.1 release.

Nathan

Please roll this change back. If you add a custom class in src/main/java/your/package/CustomClass.java you will get ClassNotFoundException! 


Currently (2.0.3) liquibase maven plugin fails to find classes in standard maven java classes folder.



I tested 2.0.0 and it works fine!