Application Client access EJB on Glassfish via a remote interface. Can I do it via local interface?

The EJB FAQ on the Glassfish site addresses this question and it is quite clear that it is not possible, unless you use the embedded container: I have an EJB component with a Local interface. Can I access it from an Application Client or a stand-alone java client? If the EJB component is running within the server, no.

The EJB Local view is an optimized invocation path that uses call-by-reference semantics. It is only available to web components and EJB components that are part of the same application as the target EJB component. To access EJB components that are running in the server from an Application Client or stand-alone java client, you'll need to use either a Remote 3.

X Business interface, a 2. X Home interface, or web services One alternative, if using GlassFish v3, is to use the EJB 3.1 Embeddable API. This allows a Java SE program to directly execute EJB components within the same JVM, without using a server process The next question also gives a hint on why this is the reason - the Java EE specification has never explicitly specified that local interfaces MUST be accessible across multiple applications in the same JVM/container Application server vendors, therefore, have never done this, except for one or two cases.

Most of the reasons eventually boil down to classloaders - the EJB module has it's own classloader (which sometimes is also the application classloader), and if the local interface has to be shared across multiple applications, then all of them must share the same classloader, or the application server must load the interface classes in a parent classloader.

The EJB FAQ on the Glassfish site addresses this question, and it is quite clear that it is not possible, unless you use the embedded container: I have an EJB component with a Local interface. Can I access it from an Application Client or a stand-alone java client? If the EJB component is running within the server, no.

The EJB Local view is an optimized invocation path that uses call-by-reference semantics. It is only available to web components and EJB components that are part of the same application as the target EJB component. To access EJB components that are running in the server from an Application Client or stand-alone java client, you'll need to use either a Remote 3.

X Business interface, a 2. X Home interface, or web services. One alternative, if using GlassFish v3, is to use the EJB 3.1 Embeddable API.

This allows a Java SE program to directly execute EJB components within the same JVM, without using a server process. The next question also gives a hint on why this is the reason - the Java EE specification has never explicitly specified that local interfaces MUST be accessible across multiple applications in the same JVM/container. Application server vendors, therefore, have never done this, except for one or two cases.

Most of the reasons eventually boil down to classloaders - the EJB module has it's own classloader (which sometimes is also the application classloader), and if the local interface has to be shared across multiple applications, then all of them must share the same classloader, or the application server must load the interface classes in a parent classloader.

Thank you, that is very clear – Harry Pham Jun 15 at 19:03 @Harry, You're welcome. Thanks for the feedback. – Vineet Reynolds Jun 15 at 20:32.

It uses a remote interface because the application client is in a separate JVM than the EJB server. The only way to talk between the two is via a socket. What you're are talking about is something more akin to an embedded EJB server, that's embedded in the client.

That's not what the app client model is supporting. GFv3 can be embedded, so it can be done, but it's not a described part of the JEE model or profiles, where the app client model is part of the JEE spec.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions