4 Replies Latest reply on Apr 5, 2012 5:45 AM by Damien Picard

    Web Application JNDI configuration

    Damien Picard Newbie



      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 :



      <resource-ref id="res_1">

                          <description>Fichier de configuration test</description>








      I declare a datasource with the JBoss admin and I bind it in the jboss-web.xml :











      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.

        • 1. Re: Web Application JNDI configuration
          Stephen Coy Master

          Hi Damien, welcome to the JBoss Forums!


          We need to know a bit more abot your production and test environments.


          Ideally, you should have a test environment that is a replica (aside from network addresses) of your production environment. This includes setting up resources such as datasources with the same JNDI names in both environments. That way you or your deployment team never need to touch the deployment descriptors.

          • 2. Re: Web Application JNDI configuration
            Damien Picard Newbie

            Hi Stephen,


            Thank you for your reply.


            In fact we have a test environment that is a replica of the production environment.

            To write the JNDI name of the used resource "hardly" in the deployment descriptor bother me because the deployment configuration is setted into the artifact : if the deployment team wants to change a resource name (nevermind the cause), they have to tell it to the development team (who will change the parameter in the build configuration for example), and we have to rebuild and redeploy the artifact.


            Furthermore, if I want to deploy, for example, one webservice in two different versions, they will mandatory use the same resources (and this is my real use case). In the case of a datasource, this is not annoying because this is probably what we want to do. But in the case of a simple String parameter, this could be bothersome.

            • 3. Re: Web Application JNDI configuration
              Stephen Coy Master

              As the server JNDI namespace is effectively global, all I can suggest is that you include a version component in your JNDI names.

              • 4. Re: Web Application JNDI configuration
                Damien Picard Newbie

                Thank you, this is exactly what I'm thinking about.


                I've just another question around JNDI configuration ; is there a way in JBoss AS 7 to modify a JNDI String value in the administration ?