Search code examples
javajvmejb-3.0

EJB3 Local and Remote interfaces


I understood that Local interface is designed for clients in the same container's JVM instance and remote interface is designed for clients residing outside the EJB container's JVM. How about the web application client which is not reside (or packaged) in the same .ear but reside on the same Java EE server?


Solution

  • Officially @Local annotated beans can only be accessed if they're in the same application. A .war deployed separately from an .ear (or other .war or other .jar EJB) is a different application, even when deployed to the same application server instance.

    There's thus no guarantee that the code in your .war can call @Local EJB beans that are defined in the .ear.

    However, in practice in nearly all application servers this just works.

    There's a request for the EJB 3.2 spec to officially support local cross-application calls: https://download.oracle.com/otndocs/jcp/ejb-3_2-fr-spec