DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34415>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34415

           Summary: [configuration]  PropertiesConfiguration constructor
                    doesn't load resource from classpath.
           Product: Commons
           Version: 1.1.0
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Configuration
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


The PropertiesConfiguration(String fileName) constructor incorrectly handles the
fileName when the file name points to a configuration resource to be loaded from
the classpath.

Test case:
mkdirs example/package/configuration/
make file example/package/configuration/test.properties containing
test.stuff=This is test stuff

This code somewhere in above classpath
PropertiesConfigurations test1 =
PropertiesConfiguration("example/package/configuration/test.properties");
Causes Exception
org.apache.commons.configuration.ConfigurationException: Cannot locate
configuration source test.properties
       at
org.apache.commons.configuration.AbstractFileConfiguration.load(AbstractFileConfiguration.java:183)
...
(Note only file part of resource path)

If this is done
PropertiesConfiguration test2 = new PropertiesConfiguration();
test.setFileName("example/package/configuration/test.properties");
test.load();

Configuration is loaded and properties can be accessed.

Problem seems to be that, AbstractFileConfiguration(String) calls set path which
creates a File and breaks the string into basePath and fileName components. 
Then load() occurs load occurs calling ConfigurationUtils.locate(basePath,
fileName).  ConfigrationsUtils.locate(String, String) only uses fileName when
looking for the resource on the system or context classpaths.

Solution (maybe) to do things more like XMLConfiguration.
Will submit patch if i get time.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to