2 Replies Latest reply on Oct 8, 2013 6:21 AM by Naziya Syed

    Why datasource JNDI name has to start with 'java:/' or 'java:jboss/ in AS 7.1

    badr elhouari Novice

      Hi,

       

      I have to deploy the same war in glassfish 3.1 and AS 7.1 which normaly possible with the Java EE portability principle! So I need to create the same datasource with the same JNDI name in both AS 7.1 and glassfish 3.1. The problem is that AS 7.1 impose to me to start the datasource JNDI name by Java:/ or Java:jboss/ BUT glassfish don't accept a JNDI name containig : So I'm wondering why Jboss put this retriction?

       

      Thanks in advance

        • 1. Re: Why datasource JNDI name has to start with 'java:/' or 'java:jboss/ in AS 7.1
          blake ong Newbie

          Our development team uses maven jetty plugin for our local environment, and our production uses JBoss EAP 6.1

           

          All you need to do is to create a jboss-web.xml in your WEB-INF with something like below:

           

          <resource-ref>

                  <res-ref-name>jdbc/MyDS</res-ref-name>

                  <jndi-name>java:jboss/jdbc/MyDS</jndi-name>

          </resource-ref>

           

          In our web.xml we have something like this:

           

          <resource-ref>

                  <res-ref-name>jdbc/MyDS</res-ref-name>

                  <res-type>javax.sql.DataSource</res-type>

                  <res-auth>Container</res-auth>

          </resource-ref>

          • 2. Re: Why datasource JNDI name has to start with 'java:/' or 'java:jboss/ in AS 7.1
            Naziya Syed Newbie

            Hi,

             

                In the jboss_datasource  xsd files, the attribute jndi-name its type is a "token" and it is mentioned as "required" something like this :

             

                                                                 <xs:attribute name="jndi-name" type="xs:token" use="required">

             

                And so, it is required to prefix "java:" for a jndi-name,.....

                   <datasources>

                       <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">

                   </datasources>

             

             

               Hope, this helps....