i'm a little bit confused about the difference between the no-interface-view and @Local
-view in Ejb-Beans.
Beans declared with No-Interface-view can be addressed by clients which are in the same JavaEE application und beans which implements @Local
interface can be accessed by clients which are in the same JVM but possibly in separate JavaEE applications, right?
What is here the exact meaning of JVM? That beans with @Local
-interfaces are on the same server, because usually there is one Java Virtual machine per server?
Can we also say, that there is one JVM per server and each java application executing from its main method uses indepently an instance of the JVM?
Sorry for the noobie questions.
The no-interface view (@LocalBean
) and @Local
are both local interfaces and are nearly identical. The only difference is that @Local
uses a separate interface as a proxy, but @LocalBean
uses the bean class itself as the proxy (the EJB container generates a subclass that overrides all the business methods).
The EJB specification states that EJB containers only need to support local interfaces within the same application. Application servers can implement cross-application same-JVM local interfaces (@LocalBean
or @Local
), but they are not required to do so.
If you're not familiar with the terminology, it's easiest to simplify and think of "the JVM" as "the java
process". So, yes, java -cp ...
and java -jar ...
launch a single Java process containing a single JVM, and an application server process is typically a single process launched using java
, so it contains a single JVM too. And yes, you can also say that @Local
EJBs can only be invoked from the same Java process or same JVM (or typically even same Java EE application since most applications are written portably to not require cross-application local EJBs).