Liquibase Community Forum
2010-12-28 00:06:40 UTC
A new topic, 'Issue (Maybe) in Liquibase-Maven-Plugin :2.0.0', has been made on a board you are watching.
You can see it at
http://liquibase.org/forum/index.php?topic=864.new#new
The text of the topic is shown below:
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
Unsubscribe to new topics from this board by clicking here: http://liquibase.org/forum/index.php?action=notifyboard;board=1.0
Regards,
The Liquibase Community Forum Team.
You can see it at
http://liquibase.org/forum/index.php?topic=864.new#new
The text of the topic is shown below:
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
Unsubscribe to new topics from this board by clicking here: http://liquibase.org/forum/index.php?action=notifyboard;board=1.0
Regards,
The Liquibase Community Forum Team.