Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EJB3 Local and Remote interfaces

Tags:

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?

like image 749
Thurein Avatar asked Dec 15 '11 20:12

Thurein


People also ask

What is the difference between local and remote interface?

Using the remote and local interfaces appropriately means that clients can access EJB components efficiently. That is, local clients use the local interface with pass-by-reference semantics, while remote clients use the remote interface with pass-by-value semantics.

What is local interface in EJB?

The local interface is a standard Java interface. It does not inherit from RMI. An enterprise bean uses the local interface to expose its methods to other beans that reside within the same container.

What is remote interface?

In RMI, a remote interface is an interface that declares a set of methods that may be invoked from a remote Java virtual machine. A remote interface must satisfy the following requirements: A remote interface must at least extend, either directly or indirectly, the interface java.

Which annotation is required for remote view EJB?

Your EJB must now define all its business interfaces using @Local annotation so it's additional work for you. Not only you implement an interface but you need to remember to declare that your EJB is exposing it.


Video Answer


1 Answers

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

like image 62
Arjan Tijms Avatar answered Sep 18 '22 03:09

Arjan Tijms