lately a requirement came up to outsource the database settings out of Spring applicationContext.xml. Therefore we wanted to have a jdbc.properties file outside the builded jars, so the user can easily change the jdbc.settings. So far all worked fine within the eclipse workspace, but as soon as I build the distribution with ant, the applicationContext.xml doesnt find the jdbc.properties anymore.
The applicationContext.xml looks like the following:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.user}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
Within eclipse I used following classpath, so the jdbc.properties (which is placed in an eclipse project folder “config”) gonna get found:
classpath file:
<classpath>
...
<classpathentry kind="src" path="config"/>
...
</classpath>
Until here all works fine. Now I build the project with Ant. The project.jar gets created, and a seperate config folder right next to it as well with the jdbc.properties file in it. Within the Manifest.mf there is an entry:
config/jdbc.properties
But when I now start the server, the jdbc.properties are not found. I noticed, when I change the Manifest.mf entry to:
config/.
it works fine again. But I dont understand why this is different. Can anyone explain me this behaviour? Or maybe even knows what I am doing wrong? Obviously I have to change the Ant file somehow, so he just adds the config folder in the manifest file, and not only the jdbc.properties-file itself?
Thank you in advance!
Solution was to define an classpathelement within the Ant-buildscript.
Unfortunatly I still dont know, why refering directly to the file didnt solve this issue as well.