Web Application JNDI configuration
damienp Apr 3, 2012 8:53 AMHi,
This is my first message so I'd like to thank each contributor of JBoss for this work.
I have some questions regarding the JNDI configuration of a Web Application.
Currently, I've got a web application that is configured using a configuration file droped in the conf/ folder ; it works fine but for many reasons, this is not a good idea to handle the configuration as is.
So, I want to use JNDI to replace this configuration file.
I've created datasources, mail resources, etc. with JNDI, and i'm able to use it in my web app. As it has to be done, I declare the resource in the WEB-INF/web.xml :
{code:xml}
<resource-ref id="res_1">
<description>Fichier de configuration test</description>
<res-ref-name>DS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
{code}
I declare a datasource with the JBoss admin and I bind it in the jboss-web.xml :
{code:xml}
<resource-ref>
<res-ref-name>DS</res-ref-name>
<jndi-name>java:jboss/datasources/ExampleDS</jndi-name>
</resource-ref>
{code}
I package all of these files in the WAR archive, I deploy it and everything works fine.
But, (and I'm sure that i'm not the first one to want to do that) the deployment team need to be able to deploy this war archive twice, one for tests purpose, one for production.
Insofar as the datasource binding is resolved in the jboss-web.xml, the deployment team can not configure the datasource to bind to a test database.
The only solution i've found by now is to unpack the war, reconfigure the jboss-web.xml, and repack the war. But this is definitively not acceptable because the deployment team is not able to (and don't want to) do these steps.
So, how can I definitively split my application and its configuration ?
P.S. : I'm working on JBoss 5.1.0.GA and using JBoss 7.1 could be possible.