2 Replies Latest reply on Mar 1, 2007 10:06 AM by Peter Danielsen

    Migrating JavaBean <resource-ref>s from Tomcat to JBoss

    Peter Danielsen Newbie

      Hi,

      I have an application originally developed with Tomcat 5.0.28 that I'm trying to port to JBoss 3.2.8 SP1. (I'm using that version of JBoss because this application works with another application that was developed to work with 3.2.x). I've created a jboss-web.xml file to accompany WEB-INF/web.xml and an -ds.xml file for the deploy directory for connecting to a DataSource, but I haven't yet discovered how to resolve other <resource-ref>s that refer to regular JavaBeans (not EJBs) with application configuration information.

      In Tomcat, I used the method shown for "Generic JavaBean Resources" at http://tomcat.apache.org/tomcat-5.0-doc/jndi-resources-howto.html which resolves these resources by using an application-specific context file. I'd appreciate any suggestions on how to define the values of JavaBean resources in JBoss.

      Thanks,

      Peter

        • 1. Re: Migrating JavaBean <resource-ref>s from Tomcat to JBoss
          jaikiran pai Master

          If i understand your question right, you are looking for the jboss-web.xml file where you can configure this. You can find the dtd for this xml here:

          http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd

          Here's an extract:

          <!ELEMENT jboss-web (class-loading?, security-domain?, context-root?,
          virtual-host*, use-session-cookies?, replication-config?, resource-env-ref*,
          resource-ref* , ejb-ref* , ejb-local-ref*, depends*)>




          • 2. Re: Migrating JavaBean <resource-ref>s from Tomcat to JBoss
            Peter Danielsen Newbie

            Thanks for replying.

            I've already added a <resource-ref> to the jboss-web.xml file. Here's an example. The web.xml contains this:

             <resource-ref>
             <description>Logger Service Locator Configuration Bean Factory</description>
             <res-ref-name>bean/LoggerServiceLocatorConfigBeanFactory</res-ref-name>
             <res-type>com.xyz.test.webapp.LoggerServiceLocatorConfigBean</res-type>
             <res-auth>Container</res-auth>
             </resource-ref>
            

            where the res-type is the name of a JavaBean class that contains configuration data. It's not an EJB, just a regular JavaBean.
            The jboss-web.xml contains this:
             <resource-ref>
             <res-ref-name>bean/LoggerServiceLocatorConfigBeanFactory</res-ref-name>
             <jndi-name>java:/bean/LoggerServiceLocatorConfigBeanFactory</jndi-name>
             </resource-ref>
            

            to map the res-ref-name to a JNDI name.

            I'm trying to understand where and how I specify
            1. the properties of this JavaBean in JBoss?
            2. the factory JBoss should use to create the bean?
            The JBoss documentation I've found so far only takes me through the jboss-web.xml step, but doesn't explain how values are assigned to JNDI names. In Tomcat, an application-specific context file under $TOMCAT/conf/Catalina/localhost identifies the factory and the JavaBean properties, as shown in the documentation referenced in my original post. I also looked at WebSphere and saw how to do both these actions there, so I'm thinking there must be a similar feature in JBoss.

            Thanks again for your assistance.