Affects Version/s: None
Fix Version/s: None
Operating System: All
I found a thread on the commons mailing list about this topic, but did not see a
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:
properties/config.xml <= The ConfigurationFactory settings
properties/test-config.xml <= An XML properties file
com.test.ConfigurationTest <= Constructs ConfigurationFactory and calls
Because I use the classload to load
<!-- config.xml -->
I have tried many variations of the above path to get it to load from the
classpath to no avail, such as:
Most of the time it coughs out a SAXException with a garbled path like this:
Could not load from
In other words, I can't seem to make it use the appropriate URL for accessing
the file when it's in another JAR.
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.