Failing JNDI Lookup from Servlet to Stateless Session bean
andrigtmiller Sep 8, 2005 11:51 AMI have been building a prototype application using the JBoss IDE 1.5 M2, and am having a problem where the servlet cannot lookup the Stateless Session bean. I have looked over all the code and deployment descriptors and cannot find anything that explains the problem. Here is the exception I am getting:
javax.servlet.ServletException: Lookup of java:/comp/env/ejb/Order failed
at services.web.NewOrderServlet.init(NewOrderServlet.java:52)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:816)
note
The exception is not really helpful and there is nothing else in the JBoss logs. Here is my servlet code for the JNDI lookup:
public void init(ServletConfig config) throws ServletException { super.init(config); try { Context context = new InitialContext(); Object reference = context.lookup("java:/comp/env/ejb/Order"); home = (OrderHome) PortableRemoteObject.narrow(reference, OrderHome.class); } catch (Exception e) { throw new ServletException("Lookup of java:/comp/env/ejb/Order failed"); } }
Here are the deployment descriptors as well:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd"> <jboss-web> <!-- Resource Environment References --> <!-- For additional resouce-env-ref tags add a merge file called jbossweb-resource-env-ref.xml --> <!-- Resource references --> <!-- For additional resouce-ref tags add a merge file called jbossweb-resource-ref.xml --> <!-- EJB References --> <!-- For additional ejb-ref tags add a merge file called jbossweb-ejb-ref.xml --> <ejb-ref> <ejb-ref-name>ejb/Order</ejb-ref-name> <jndi-name>ejb/Order</jndi-name> </ejb-ref> <!-- EJB Local References --> <!-- For additional ejb-local-ref tags add a merge file called jbossweb-ejb-local-ref.xml --> </jboss-web>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd"> <ejb-jar > <description>[CDATA[No Description.]]</description> <display-name>Generated by XDoclet</display-name> <enterprise-beans> <!-- Session Beans --> <session > <description>[CDATA[This Order Service can create new Orders]]</description> <display-name>Order Service</display-name> <ejb-name>Order</ejb-name> <home>services.interfaces.OrderHome</home> <remote>services.interfaces.Order</remote> <ejb-class>services.ejb.OrderBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> <!-- To add session beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called session-beans.xml that contains the <session></session> markup for those beans. --> <!-- Entity Beans --> <!-- To add entity beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called entity-beans.xml that contains the <entity></entity> markup for those beans. --> <!-- Message Driven Beans --> <!-- To add message driven beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called message-driven-beans.xml that contains the <message-driven></message-driven> markup for those beans. --> </enterprise-beans> <!-- Relationships --> <!-- Assembly Descriptor --> <assembly-descriptor > <!-- To add additional assembly descriptor info here, add a file to your XDoclet merge directory called assembly-descriptor.xml that contains the <assembly-descriptor></assembly-descriptor> markup. --> <!-- finder permissions --> <!-- transactions --> <!-- finder transactions --> </assembly-descriptor> </ejb-jar>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd"> <jboss> <enterprise-beans> <!-- To add beans that you have deployment descriptor info for, add a file to your XDoclet merge directory called jboss-beans.xml that contains the <session></session>, <entity></entity> and <message-driven></message-driven> markup for those beans. --> <session> <ejb-name>Order</ejb-name> <jndi-name>ejb/Order</jndi-name> <method-attributes> </method-attributes> </session>
And ideas would be helpful.
Thanks.