After I defined this in the war's web.xml:
<ejb-local-ref>
<ejb-ref-name>ejb/cart</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>com.mellon.StatefulSBLocal</local>
</ejb-local-ref>
then I can lookup this
ejb in a
servlet via:
InitialContext ctx = new InitialContext();
StatefulSBLocal cart = (StatefulSBLocal) ctx.lookup("java:comp/env/ejb/cart");
cart.persist();
Should I define the ejb ref in web.xml to lookup an EJB?
Can I access an EJB in Servlet without defining an ref in web.xml or annotating it by @EJB?
I tried to lookup my StatefulSBBean with JNDI names as "java:comp/env/ejb/StatefulSBBean", "ejb/StatefulSBBean" ...
Failed every time.
[ December 21, 2008: Message edited by: Mellon Sun ]
SCJP,SCWCD1.3,SCWCD1.4,SCJD,SCBCD5,SCEA5