views:

48

answers:

1

I want to call ejb from servlet via remote interface. Maybe it is a RTFM question but i cannot find solution via Google or documentation. What configuration steps I need to do than ejb be accessible for webapps

I use Jboss 4.2, Java 1.6

Thanks for your answer!

+2  A: 

Place this in your servlet:

@EJB
private YourEJBRemoteInterface remoteService;

And you will have your service injected. (you may need to set the name of the @EJB annotation)

Another way is to use JNDI lookup, but this is obsolete.

Update: Since your JBoss version seems obsolete as well, the JNDI lookup is the way to go. int your servlet init(..) method lookup the EJB through JNDI (using InitialContext), and set them as fields, as if dependency-injection has been performed.

Bozho
According to this link http://www.coderanch.com/t/163667/java-EJB-SCBCD/certification/EJB-annotation-servlet-JBoss Jboss does not support EJB injection in Servlet
glebreutov
As I understand see i have asked question incorrect: I need solution how to configure webapp that way that servlets can use EJB. I have edited my question.
glebreutov
see my update..
Bozho