[
http://jira.codehaus.org/browse/MHIBERNATE-80?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=139896#action_139896
]
Casey Butterworth commented on MHIBERNATE-80:
---------------------------------------------
I've also found an alternative to going back to 2.0-alpha-2. You can get this
working with 2.1 by configuring your own {{<propertyresource>}}, with a name
other than database.properties. For example:
\\
\\
{code:xml}
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<configuration>
<components>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
</component>
</components>
<componentProperties>
<drop>true</drop>
<jdk5>true</jdk5>
<!--<propertyfile>target/test-classes/database.properties</propertyfile> (this
doesnt work) -->
<!--<propertyfile>target/test-classes/hbm2ddl.properties</propertyfile> (this
doesnt work) -->
<propertyresource>hbm2ddl.properties</propertyresource>
<!-- where hbm2ddl.properties is in src\test\resources -->
<outputfilename>schema-export.sql</outputfilename>
<format>true</format>
<configurationfile/>
</componentProperties>
</configuration>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>${jdbc.groupId}</groupId>
<artifactId>${jdbc.artifactId}</artifactId>
<version>${jdbc.version}</version>
</dependency>
</dependencies>
</plugin>
{code}
> Property files loaded from classpath regardless of whether a configured
> property file was found.
> ------------------------------------------------------------------------------------------------
>
> Key: MHIBERNATE-80
> URL: http://jira.codehaus.org/browse/MHIBERNATE-80
> Project: Maven 2.x Hibernate Plugin
> Issue Type: Bug
> Affects Versions: 2.0, 2.1
> Reporter: Casey Butterworth
> Assignee: Johann Reyes
>
> In our environment we have:
> * a {{src\main\resources\database.properties}}
> * as well as a configured {{propertyfile}} (i.e.
> {{<propertyfile>target/test-classes/database.properties</propertyfile>}}).
> Unfortunately in hibernate3-maven-plugin:2.1, this no longer works as is, as
> {{the
> org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration}}
> always loads the file from the classpath (i.e
> {{target\classes\database.properties}}, even though it can successfully find
> our propertyfile.
> This is due to the following bug on line 153 of {{the
> org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration}} :
> {{
> // If we can't find the file propertyfile and the propertyresource is
> on the
> // classpath, open it as a stream
> if(
> Thread.currentThread().getContextClassLoader().getResource(propertyResource)
> != null) {
> propInputStream =
> Thread.currentThread().getContextClassLoader().getResourceAsStream(
> propertyResource );
> }
> }}
> note that while the comment states "if we can't find the property file...",
> the conditional does not actually check whether the propertyfile was found.
> To resolve this, I think the if statement should be:
> {{
> if(propFile != null &&
> Thread.currentThread().getContextClassLoader().getResource(propertyResource)
> != null) {
> }}
> For the timebeing I've had to go back to 2.0-alpha-2.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email