3 Replies Latest reply on Dec 31, 2008 11:14 PM by jaikiran

    Migrating WAR binary from Tomcat to JBoss Web (JNDI/SAR/jbos

    dhartford

      I have a WAR binary that works in tomcat. It has datasource requirements that follow the normal TOMCAT jndi approach of /comp/env/jdbc/myDS.

      If you wanted to modify the WAR binary, yes you can add RESOURCE-REF and/or put in Resource Injection in the actual code.

      But lets say you don't, and have a 'certified' WAR binary and do not want to modify the WAR itself.

      Ideally, you create:

      myapp-datasources.sar (folder)
      -->META-INF/jboss-service.xml
      -->mydatasource-ds.xml
      -->lib/mydatabasejdbc.jar

      nope...not so easy.

      <jndi-name>myDS</jndi-name> fails
      <jndi-name>jdbc/myDS</jndi-name> fails
      <jndi-name>env/jdbc/myDS</jndi-name> fails
      <jndi-name>comp/env/jdbc/myDS</jndi-name> fails

      <use-java-context>true</use-java-context> fails (only couple of the above)

      Get errors like:

      javax.naming.NameNotFoundException: env not bound

      java.lang.RuntimeException: mapped-name is required for jdbc/myDS


      Is there anything that can be done in a SAR to map old Tomcat datasources to be usable by a WAR built for Tomcat to be usable Jboss Web without modifying the WAR?

      Thanks,
      -D

        • 1. Re: Migrating WAR binary from Tomcat to JBoss Web (JNDI/SAR/
          jaikiran

          The java:comp/env namespace if for each component. So if you want the datasource to be available in the java:comp/env namespace of the web application, then you will have to add an entry in the web.xml. That's the reason why you have the resource-ref element.

          • 2. Re: Migrating WAR binary from Tomcat to JBoss Web (JNDI/SAR/
            dhartford

             

            "jaikiran" wrote:
            The java:comp/env namespace if for each component. So if you want the datasource to be available in the java:comp/env namespace of the web application, then you will have to add an entry in the web.xml. That's the reason why you have the resource-ref element.


            Is there a resource-ref entry that you can add to web.xml that will be usable in both Tomcat and Jboss Web? Otherwise requiring the modification of the WAR is exactly what I'm trying to avoid.

            Or, is the SAR approach not correct, and could put a context.xml somewhere in Jboss Web?




            • 3. Re: Migrating WAR binary from Tomcat to JBoss Web (JNDI/SAR/
              jaikiran

               

              "hartfordd" wrote:

              Is there a resource-ref entry that you can add to web.xml that will be usable in both Tomcat and Jboss Web?



              The resource-ref entry is in the web.xml file, which is a standard file. So both Tomcat and JBossWeb will support it the same way. So yes, you can add that resource-ref entry to the web.xml and have the application portable.