This content has been marked as final.
Show 3 replies
-
1. Re: Packing/Descriptors for EJB 3.0 Local access
jaikiran Nov 4, 2006 2:40 AM (in response to schererj123)In your ejb-jar.xml:
<session > <description>Sample session bean</description> <ejb-name>HelloWorld</ejb-name> <local-home>packageName.HelloWorldLocalHome</local-home> <local>packageName.HelloWorldLocal</local> <ejb-class>packageName.HelloWorldSessionBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session>
Add the following to the web.xml:<ejb-local-ref> <ejb-ref-name>ejb/MyLocalRefHelloWorld</ejb-ref-name> <ejb-ref-type>Session</ejb-ref-type> <local-home>packageName.HelloWorldLocalHome</local-home> <local>packageName.HelloWorldLocal</local> <ejb-link>HelloWorld</ejb-link> </ejb-local-ref>
The ejb-link in the web.xml should match the ejb-name in the ejb-jar.xml.
In your code, you will lookup using the ejb-ref-name specified in the web.xml, as follows:Context ctx = new InitialContext(); ctx.lookup("java:comp/env/ejb/MyLocalRefHelloWorld");
-
2. Re: Packing/Descriptors for EJB 3.0 Local access
jaikiran Nov 4, 2006 2:42 AM (in response to schererj123)This approach will work, but you mention that you are using EJB3. Why dont you use dependency injection of EJBs?
-
3. Re: Packing/Descriptors for EJB 3.0 Local access
jaikiran Nov 4, 2006 2:49 AM (in response to schererj123)Why dont you use dependency injection of EJBs?
Hmmm... Searching the forums led me to this thread which mentions that as of now dependency injection of EJB in servlets in not possible:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=93140