I posted an earlier message regarding using the Java Pet Store 1.1.2 with
JBoss 2.2.2/Tomcat3.2.2 regarding some naming weirdness. I now think I have
a bug in Pestore 1.1.2 or it could be JBoss/Tomcat. Somebody tell me.

After the tables have been successfully populated, subsequent attempts to
access the Pet Store result in:

com.sun.j2ee.blueprints.petstore.control.exceptions.GeneralFailureException:
CatalogDAOFactory.getDAO:  NamingException while getting DAO type :
catalog not bound
        at
com.sun.j2ee.blueprints.petstore.control.web.CatalogWebImpl.(CatalogWebImpl.
java:36)
        at
com.sun.j2ee.blueprints.petstore.control.web.ModelManager.getCatalogModel(Mo
delManager.java:84)
        at
com.sun.j2ee.blueprints.petstore.control.web.ModelManager.init(ModelManager.
java:61)
        at
com.sun.j2ee.blueprints.petstore.control.web.MainServlet.doGet(MainServlet.j
ava:83)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
        at org.apache.tomcat.core.Handler.service(Handler.java:287)
        at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
        at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
        at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
        at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:213)
        at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
        at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
        at java.lang.Thread.run(Thread.java:496)

The problem here is that the class 'CatalogWebImpl' invokes a factory class,
'CatalogDAOFactory' which tries to do a lookup for a resource in jndi using
"java:comp/env/ejb/catalog/CatalogDAOClass" (a hardcoded constant used by
'CatalogDAOFactory'). The problem is the <env-entry> tags in the deployment
descriptor scope this name to the Catalog session bean:

    <session>
      <description>This is the Catalog ejb</description>
      <display-name>The Catalog</display-name>
      <ejb-name>TheCatalog</ejb-name>

<home>com.sun.j2ee.blueprints.shoppingcart.catalog.ejb.CatalogHome</home>

<remote>com.sun.j2ee.blueprints.shoppingcart.catalog.ejb.Catalog</remote>

<ejb-class>com.sun.j2ee.blueprints.shoppingcart.catalog.ejb.CatalogEJB</ejb-
class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <env-entry>
        <env-entry-name>ejb/catalog/CatalogDAOClass</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>

<env-entry-value>com.sun.j2ee.blueprints.shoppingcart.catalog.dao.CatalogDAO
Impl</env-entry-value>
      </env-entry>
      <resource-ref>
        <res-ref-name>jdbc/EstoreDataSource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
      </resource-ref>
    </session>

"/ejb/catalog/CatalogDAOClass" is not registered anywhere else. The problem
is because the factory is called by both the Catalog session bean and by
'CatalogWebImpl' which, as you can see in the stack trace above, is called
directly by the servlet without the bean intevening and as a result there is
no equivalent 'java:comp/env' context to work off of.

The troubling part is this that there are many calls for other factories
that do the exact same thing.

The puzzling question remains, how is it that this works on J2EE RI and not
JBoss? Moreover, how would I make this variable available in JNDI to both
callers?

j.



_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to