NullPointerException while accessing .Properties from JAR
807580Jul 8 2010 — edited Jul 9 2010Hi,
I have created a JAR file which contains the .class as well as .properties in my application. Similarly when generating the JAR i have included the respective JAR's as well as the Main class of the app. in the Manifest.MF file.
Below is the code i am using to load the properties from the LoggerConstants.
if (properties == null) {
try {
properties = new Properties();
properties.load(Thread.currentThread().getContextClassLoader()
.getResourceAsStream (LoggerConstants.LOGGER_PROPERTIES_PATH));
PropertyConfigurator.configure(properties);
} catch (IOException ioe) {
throw new LoggerException("unable to load file="
+ LOGGER_PROPERTIES_PATH, ioe);
}
}
When i access the JAR in other app. by putting that in the build path, i am getting the following exception:-
Exception in thread "main" java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:418)
It seems that it is not able to pick the .properties which is there in the JAR file? But it is able identify the .class file?
I tried by copying the same in the ANT Class path in eclipse, but still the problem persists. What i need to make sure that the .properties will be identified by the other app (App. 2)? Please shed some light into this.
Thanks,
Rithu