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.1, 2.0
            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


Reply via email to