I have a strange problem with Spring using PropertyPlaceholderConfigurer
. One of my beans is designed as follow :
<bean name="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean>
The problem is that spring never find jdbc.properties (FileNotFoundException
). The file is in a folder named "resources" that is in the bundle classpath (I am working in a OSGi project).
I have tried almost every combination ("jdbc.properties", "/jdbc.properties", "classpath:jdbc.properties", "classpath:/jdbc.properties", "/resources/jdbc.properties", etc...) but it never works.
For information, if at some point, I do something like :
URL u = someClassLoader.getResource("jdbc.properties");
it does work without any problem and find the file. Actually I am totally unable to understand what is the bug with spring.
If you have any idea to help me, thanks in advance. I am not very experienced in spring so I have maybe done a mistake somewhere.
[EDIT]
Actually, it's a problem of classloader : If I do :
new ClassPathResource("jdbc.properties");
it doesn't work. But :
new ClassPathResource("jdbc.properties",someClassIntheBundle.class.getClassLoader());
works perfectly.
I do believe that Spring use the ClassLoader of its own bundle that is consumed by my bundle. Do you know a way to solve this tricky problem ?
Thanks,