aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Question related to Application Server and Container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Question related to Application Server and Container" Watch "Question related to Application Server and Container" New topic
Author

Question related to Application Server and Container

Sagar Shroff
Ranch Hand

Joined: Jun 07, 2011
Posts: 202

My understanding of how mostly all app-servers work is that they have a separate container for web components and a separate container for ejb component.
Now my query is lets take Local view in EJB for example . The basic semantics that Local view follows is Call by reference ,so that makes sense that if a client needs to access a service with a local view , both the client and the service needs to be in same JVM . But now if my web component which is running on a web container need to access the ejb service running on EJB container it is compulsory for the web component to use the remote view. So is my understanding correct that each container have their own Jvm though on a single server machine ??

Q2) Another doubt i have is that why EJB spec have stated the following rule as compulsion with local view ,
if my client (ejb) and service (ejb) and if both of them are packaged in separate EJB archive then local view is not possible . Why so ?? why both the client and the service needs to be a part of a single Ear file because in this example both client and service is an EJB so they will go in the same container and hence same JVM , so it does not matter whether it is same Ear or different Ear . Can some one clear my above 2 doubts ?


Regards,
Shroff.


OCJP-90%,OCPWCD-95%
Amir Keibi
Ranch Hand

Joined: Apr 23, 2012
Posts: 49

Your questions are kinda related. So I'll try to answer at once.

In app server, you are dealing with different Class Loaders, not different JVMs. Each application has its own class loader. So if you package your web application's war file and EJB's jar in one "ear" file and deploy the whole thing as one application, since both are using the same class loader, they are in each other's sight and thus a local interface will suffice (in that case you can use Dependency Injection to, for example, inject your EJBs onto your Servlets). If you deploy them separately though, they'll be separate applications. Then the only way these classes can find each other is through JNDI. JNDI uses remote interface to generate the Binding Name.

Does this help?
Sagar Shroff
Ranch Hand

Joined: Jun 07, 2011
Posts: 202

Amir Keibi wrote:Your questions are kinda related. So I'll try to answer at once.

In app server, you are dealing with different Class Loaders, not different JVMs. Each application has its own class loader. So if you package your web application's war file and EJB's jar in one "ear" file and deploy the whole thing as one application, since both are using the same class loader, they are in each other's sight and thus a local interface will suffice (in that case you can use Dependency Injection to, for example, inject your EJBs onto your Servlets). If you deploy them separately though, they'll be separate applications. Then the only way these classes can find each other is through JNDI. JNDI uses remote interface to generate the Binding Name.

Does this help?

Thank you for your answer .
So my first point was wrong right ? I thought that the only way a web component can access an ejb component is through a remote view, it can also be accesed using local view if they are packaged as a single EAR ? right ?

Regards,
Shroff
Amir Keibi
Ranch Hand

Joined: Apr 23, 2012
Posts: 49

1) Yes and 2) Yes.

This is from EJB 3.1's spec (JSR-318):

Access to an enterprise bean through the local client view is only required to be supported for local clients packaged within the same application as the enterprise bean that provides the local client view.
Compliant implementations of this specification may optionally support access to the local client view of an enterprise bean from a local client packaged in a different application. The configuration requirements for inter-application access to
the local client view are vendor-specific and are outside the scope of this specification. Applications relying on inter-application access to the local client view are non-portable.




This means, there might be some application servers that use local interface to access an EJB from another application in the same application server instance. Even if that's the case, if you deploy your EJB and its client as two separate applications you should always provide remote interface.
Sagar Shroff
Ranch Hand

Joined: Jun 07, 2011
Posts: 202

Amir Keibi wrote:
This means, there might be some application servers that use local interface to access an EJB from another application in the same application server instance. Even if that's the case, if you deploy your EJB and its client as two separate applications you should always provide remote interface.

Thanks a lot

Regards,
Shroff
 
Don't get me started about those stupid light bulbs.
 
subject: Question related to Application Server and Container
 
Similar Threads
Call EJB3.1 using Local interface
classpath woes
EJB Question
Injecting a Stateful Session Bean into a servlet
Problem referencing EJB in web application on Websphere