I have developed a native application (in SWT) using spring that needs to access a properties file, as follows:
The "location" property expects a classpath resource, which is accessible just fine when I run the application normally (i.e., not from within a jar). I just add the directory where the properties file is stored to the classpath JVM argument.Code:<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"><value>/myapp.properties</value></property> </bean>
However, when I try to package my code into a jar file, I get:
Even though my manifest file has the directory of the properties file in its "Class-Path" entry.Exception in thread "main" org.springframework.beans.factory.BeanInitializati onException: Could not load properties from class path resource [myapp.properties]; nested exception is java.io.FileNotFoundException: Could not open class path resource [myapp.properties]
When I output the system property java.class.path, I get simply my jar file. Is it possible that spring's class resource loader is not seeing past the jar file to look into the Class-Path specified in the manifest? This has been a very sticky problem and I would appreciate any help you can offer.