When using Spring Batch Admin, it tries to provide some defaults for dataSource, transactionManager etc.
If you want to override these defaults, you create your own xml bean definitions under META-INF/spring/batch/servlet/override/ folder and during the bootstrap it guarantees that the default properties will be overridden.
In spring-batch-admin, a dataSource default is defined in data-source-context.xml with this definition
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${batch.jdbc.driver}" />
<property name="url" value="${batch.jdbc.url}" />
<property name="username" value="${batch.jdbc.user}" />
<property name="password" value="${batch.jdbc.password}" />
<property name="testWhileIdle" value="${batch.jdbc.testWhileIdle}"/>
<property name="validationQuery" value="${batch.jdbc.validationQuery}"/>
</bean>
Now, I want to override this dataSource with a JNDI datasource so I removed the property lines like batch.jdbc.driver
, batch.jdbc.url
and have the following jndi definition
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/dbconn" />
</bean>
As you may easily guess the system first tries to initialize the dataSource bean defined in data-source-context.xml and since it cannot find any values for property values batch.jdbc.* it fails with an exception.
Could not resolve placeholder 'batch.jdbc.driver' in string value [${batch.jdbc.driver}]
Since I will be using JNDI and do not want to deal with these property values, I cannot proceed.
Any idea on how to override dataSource in this situation?