This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Query regarding @EJB in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Query regarding @EJB in servlet " Watch "Query regarding @EJB in servlet " New topic

Query regarding @EJB in servlet

Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 136

My application structure is as follows:
1) I have a JAR file containing EJB interfaces. Lets call it EJBClient.jar.
It is placed in WEB-INF/lib directory of a web application.

2) I have another JAR of actual EJBs implementing above interfaces. This JAR is pacakged as an EAR and deployed on JBoss.
EAR name is echoejb.ear

3) JBoss prints JNDI names of registered EJBs on console.

4) Now, in servlet, I am using @EJB(lookup="lookup-string"), but I am getting following exception:
Can not set ejb.EchoBeanRemoteInterface field org.cts.servlet.WebServlet.remoteEcho1 to ejb.EchoBeanRemoteInterface$$$view6

What does this mean?

I tried looking up using InitialContext but same result
For look-up, I am using global namespace.

5) If EJB implementation jar is placed in the same web application, look-up is successful.

Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 136

Issue resolved!

I had not annotated the interface with Local or Remote. Look-up is successful now.
I agree. Here's the link:
subject: Query regarding @EJB in servlet
Similar Threads
Packaging and Class Loaders
Global JNDI access with EJB 3.1 and JBoss 6
Packaging an EAR
JNDI: java:comp/env bound and unbound at the same time?
How to get application ear file name using Java code for JNDI lookup