0 Replies Latest reply on Aug 2, 2006 1:08 PM by ollip

    Problem with Generic JavaBean Resources

      Hi,

      I use JBoss 4.0.2 with Tomcat running inside JBoss (hence no external JNDI lookup needed). I want to define a plain Generic JavaBean Resources aka POJO as described in http://tomcat.apache.org/tomcat-4.1-doc/jndi-resources-howto.html ==> Generic JavaBean Resources.

      I have made the respective entries in the Tomcat web.xml and in JBoss' jboss-web.xml.

      Entry in web.xml:

      <resource-ref>
      <res-ref-name>bean/MyBeanFactory</res-ref-name>
      <res-type>foo.MyBean</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      Entry in jboss-web.xml:

      <resource-ref>
      <res-ref-name>bean/MyBeanFactory</res-ref-name>
      <res-type>foo.MyBean</res-type>
      <jndi-name>java:/MyBeanFactory</jndi-name>
      </resource-ref>

      This also seems to be correct since JBoss throws an exception at startup if I make both entries to mismatch on purpose otherwise no exception is thrown.

      Now I get a javax.naming.NamingException when I execute the following code in my servlet (javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: ConnectionParamsFactory not bound]):

      Context initCtx = new InitialContext();
      Context envCtx = (Context) initCtx.lookup("java:comp/env");
      MyBean myBean = (MyBean) envCtx.lookup("bean/MyBeanFactory");

      This does not worry me all that much since my bean's attributes have not been defined so far and the looked up bean would not contain any useful configuration data for me. Nevertheless, when I look into the envCtx in the debugger I see that an entry for bean/MyBeanFactory exists.

      Defining the bean's attributes, though, seems exactly to be the problem. I define a Context in Tomcat's server.xml (which is located in jboss-4.0.2\server\default\deploy\jbossweb-tomcat55.sar if I'm right) to do so:

      <Host ... >
      <Context reloadable="true" crossContext="true">
      <Resource name="bean/MyBeanFactory" auth="Container" type="foo.MyBean" />
      
      <ResourceParams name="bean/MyBeanFactory">
      <parameter> <!-- whatever params -->
      <name>language</name>
      <value>de</value>
      </parameter>
      </ResourceParams>
      
      </Context>
      </Host>
      
      (Had to display this as code since the sucks wouldn't display correctly otherwise for whatever reason.)
      


      But this doesn't do the job. I still get the same exception. I have tried zillion different ways to define the context in the server.xml but was not successful. Now I need somebody's help to get the problem found.

      Thanks for any suggestions,
      Oliver Plohmann