File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Access EJB from different EAR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Access EJB from different EAR" Watch "Access EJB from different EAR" New topic

Access EJB from different EAR

Mukesh Mittal
Ranch Hand

Joined: Jan 13, 2006
Posts: 31

If I have two EAR file. I want to acess EJB of Ear 1 from web application of EAR2. Can we do it? Do we have J2EE standard for that? Is it Servler specific?

Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
You can't use EJB linking in the deployment descriptor, but they can still talk to each other. Not sure if local interfaces would work (never tried it across ears) but remote interfaces and JMS-based communications would definitely work.

Reid - SCJP2 (April 2002)
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
The J2EE standard is that the client obtains an InitialContext (needs to pass in the right environment variables into the constructor) and uses it to do a JNDI lookup of the EJB's home. You are now on the home straight. (Sorry, bad joke. :roll: ) The stub returned needs to be narrowed and cast to the EJB's home interface. For a stateless session bean, the home stub is then used to obtain the remote EJB object stub (used to call business methods).

SCJP 1.4, SCWCD 1.3, SCBCD 1.3
I agree. Here's the link:
subject: Access EJB from different EAR
It's not a secret anymore!