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

    Problem with Generic JavaBean Resources

    Oliver Plohmann Newbie


      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:


      Entry in jboss-web.xml:


      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 -->
      (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