How to access ejb from another application

Discussions

EJB design: How to access ejb from another application

  1. How to access ejb from another application (2 messages)

    Hello! I have 2 applications deployed on my jBoss. Can anyone explain to me how can I from EAR1 access Session or Entity Bean in EAR2? Thanks!
  2. If you know how to access your beans in ear2 from a normal java client, it is straight forward. The beans in your ear1 are just clients to your ear2. You just have to make the client related interfaces & classes of ear2 available to ear1. Since your EARs using same JVM you can access them using local interfaces. Subramanian, Kumar [kumar at eminenttech dot com] J2EE Architect Eminent Technology Solutions (ETS) [www.eminenttech.com] Software / Portals / Alfresco / Outsourcing / Proteomics
  3. The safest way is to have the EJBs in EAR2 expose remote interfaces. Then, EAR1 behaves as a normal Java client. You look up the interfaces from JNDI. Depending on your application server, you may need to tweak the permissions to allow EAR1 to do lookups on JNDI in the EAR2 namespace. Using local interfaces may or may not be possible. In OC4J, for example, you can use local interfaces ONLY if EAR1 is deployed as a sub-application of EAR2. I believe the underlying reasons have to do with the fact that EAR2 could be deployed as a distributed application (hence, it is possible for EAR1 and EAR2 to be running in different JVMs). Other app servers have different rules. Read the documentation. Note, also, that some application servers are able to optimize remote operations and use a local invocation when they detect that the two endpoints are in the same JVM. So, remote interfaces are not quite as expensive as they used to be. Ara