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=30856>. 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=30856 ConfigurationFactory loading from classpath issue Summary: ConfigurationFactory loading from classpath issue Product: Commons Version: unspecified Platform: PC OS/Version: Windows XP Status: NEW Severity: Normal Priority: Other Component: Configuration AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I found a thread on the commons mailing list about this topic, but did not see a resolution presented. http://www.mail-archive.com/[EMAIL PROTECTED]/msg07782.html It seems the only way to load a properties file from a separate jar in the classpath is to use absolute paths. I believe the ConfigurationFactory framework would be a tad more useful if it used the classloader to load the properties files as resources instead. The major advantage being that one could package a default properties file in a config jar, but temporarily override it by placing a copy higher in the classpath. There are other uses as well, but that's the main use case I have in mind right now. Let's say I have the following JAR that contains only these configuration files: core-config properties/config.xml <= The ConfigurationFactory settings properties/test-config.xml <= An XML properties file core-configtest com.test.ConfigurationTest <= Constructs ConfigurationFactory and calls getConfiguration() Because I use the classload to load <!-- config.xml --> <configuration> <xml fileName="test-config.xml"/> </configuration> I have tried many variations of the above path to get it to load from the classpath to no avail, such as: <xml fileName="properties/test-config.xml"/> <xml fileName="/properties/test-config.xml"/> <xml fileName="file:test-config.xml"/> <xml fileName="file:properties/test-config.xml"/> <xml fileName="file:/properties/test-config.xml"/> Most of the time it coughs out a SAXException with a garbled path like this: Could not load from C:\dev\Java\Core-ConfigTest\file:\C:\dev\Java\Core-ConfigTest\lib\core-config.jar!\properties\test-config.xml at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540) at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566) at org.apache.commons.digester.Digester.endElement(Digester.java:1061) In other words, I can't seem to make it use the appropriate URL for accessing the file when it's in another JAR. jar:file:/C:/dev/Java/Core-ConfigTest/lib/core-config.jar!/properties/config.xml If I move the properties folder to the JAR that contains the test class, it works fine. I believe I could also use an absolute path to the properties file, but again, that precludes me from being able to quickly override the properties file by placing a copy higher in the classpath. This is my first experience with trying to initiate a change in an open source project, so bear with me if I'm not following the right protocol. I'd like to take a stab at creating a patch myself if someone hasn't already beat me to it. Thanks. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
