users@glassfish.java.net

Cannot lookup an EJB in JNDI from a servlet.

From: <glassfish_at_javadesktop.org>
Date: Tue, 22 May 2007 09:49:11 PDT

A have an EAR containing an ejb.jar and a web.war in the root of the EAR.

ejb.jar contains an only Session Stateless Bean, the WAR contains an only JSP. Here is the code in the JSP:

LocalTheSlsbHome home = (LocalTheSlsbHome)new InitialContext()
                .lookup(LocalTheSlsb.class.getName());
LocalTheSlsb slsb = home.create();
slsb.log(msg);

Here is the excerpt from sun-ejb-jar.xml:

<sun-ejb-jar>
        <enterprise-beans>
                <ejb>
                        <ejb-name>TheSlsbEJB</ejb-name>
                        <jndi-name>gft.LocalTheSlsb</jndi-name>
                        <pass-by-reference>false</pass-by-reference>
                        <bean-pool>
                                <steady-pool-size>0</steady-pool-size>
                                <resize-quantity>1</resize-quantity>
                                <max-pool-size>1</max-pool-size>
                                <pool-idle-timeout-in-seconds>10</pool-idle-timeout-in-seconds>
                        </bean-pool>
                </ejb>
        </enterprise-beans>
</sun-ejb-jar>

The application is deployed successfully. But trying to run the JSP I can see the stack trace in the server.log:

[#|2007-05-22T18:52:50.989+0400|SEVERE|sun-appserver-pe9.0|javax.enterprise.system.container.web|_ThreadID=15;_ThreadName=httpWorkerThread-8080-1;_RequestID=d9128647-95e4-49a4-9451-00e52ad550de;|StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
javax.naming.NameNotFoundException: gft.LocalTheSlsb not found
        at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:203)
        [ the rest is skipped... ]
|#]


Does anyone know what's wrong? And who's wrong?

Thanks!
[Message sent by forum member 'danissimo' (danissimo)]

http://forums.java.net/jive/thread.jspa?messageID=218371