0 Replies Latest reply on Feb 19, 2014 3:45 AM by Hlulani Mhlongo

    Disabling/remapping java context ("java:/") JNDI in Jboss 7

    Hlulani Mhlongo Newbie

      Hello

       

      I'm trying to create a portable application that can be deployed in both JBoss AS 7  & Glassfish 3, the problem is that JBoss prefixes my DataSource and Resource Adapter with java:/

      of which glassfish does NOT support.

       

      I was able to resolve this in the web (test-web.war) application for adding WEB-INF/jboss-web.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss-web>

          <context-root>/test-web</context-root>

          <resource-ref>

             <res-ref-name>eis/test</res-ref-name>

              <!--<mapped-name>java:/eis/test</mapped-name>-->

              <jndi-name>java:/eis/test</jndi-name>

          </resource-ref>

          <resource-ref>

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

              <!--<mapped-name>java:/jdbc/test</mapped-name>-->

              <jndi-name>java:/jdbc/test</jndi-name>

          </resource-ref>

      </jboss-web>

       

      The WAR file is now completely portable.

       

      But I want to do the same for the EJB that is embedded in the test-ra.rar (Resource adapter) or test-ejb.jar.

      Is there a way to reference JNDI resources like in the web.xml/jboss-web.xml for standalone EJBs?

      I've tried adding references in the jboss-ejb3.xml as suggested by jboss-ejb3.xml Reference - JBoss AS 7.1 - Project Documentation Editor:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <jboss:ejb-jar xmlns:jboss="http://www.jboss.com/xml/ns/javaee"

                     xmlns="http://java.sun.com/xml/ns/javaee"

                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                     xmlns:c="urn:clustering:1.0"

                     xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-ejb3-2_0.xsd http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"

                     version="3.1"

                     impl-version="2.0">

       

          <enterprise-beans>

             <session>

                  <ejb-name>AuditLogBean</ejb-name>

                  <ejb-class>test.ejb.AuditLogBean</ejb-class>

                  <resource-ref>

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

                      <!--<mapped-name>java:/jdbc/test</mapped-name>-->

                      <jndi-name>java:/jdbc/test</jndi-name>

                  </resource-ref>

              </session>

          </enterprise-beans>

      </jboss:ejb-jar>

       

      I've also tried the use-java-context="false" attribute when defining the datasource with no luck:

      ...

      <datasource jta="false" jndi-name="java:/jdbc/test" pool-name="testPool" enabled="true" use-java-context="false" use-ccm="true">

           <connection-url>jdbc:postgresql://localhost:5432/test</connection-url>

           <driver-class>org.postgresql.Driver</driver-class>

           <driver>postgresql</driver>

           <security>

        <user-name>test</user-name>

        <password>test@db</password>

           </security>

           <validation>

        <validate-on-match>false</validate-on-match>

        <background-validation>false</background-validation>

           </validation>

           <statement>

        <share-prepared-statements>false</share-prepared-statements>

           </statement>

        </datasource>

      ...

      ctomc

       

      Thanks alot in Advance

       

      Message was edited by: Hlulani Mhlongo