File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Doubts about EJB local client view Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Doubts about EJB local client view" Watch "Doubts about EJB local client view" New topic
Author

Doubts about EJB local client view

Kr Saurav
Greenhorn

Joined: Sep 11, 2007
Posts: 10

Hi,

I am new to EJB and preparing for the EJB 3.1 certification. I have a couple of doubts on the following:

1. If my session bean provides a local client view, does that mean local to the ear or local to the JVM. What I mean to say is that any component say a servlet in earA can it access the bean in earB within the same JVM using the local client view.

2. If my session bean provides a remote client view, then how does the remote client get to know about methods in my session bean. Also do we need to import ejb jar to the remote client, consider that my session bean is in say jboss container and the remote client in a tomcat container. How does dependency injection works in such a case considering the fact that the underlying api and the implementation would be different for different container types.

Regards,
Saurav
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1734
    
  25

Hi Saurav,

1) This is what the specs say:
  • A local client is a client that is collocated in the same JVM.
  • 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.

  • 2) You will need the remote interface in your remote client (just to get an idea: have a look at the inter-ear example in my notes ch10.2) Dependency injection doesn't work when another server is involved. You will have to use the JNDI lookup (with JNDI-properties pointing at the remote server). Inter-container communication, however is not part of the EJB certification.

    Regards,
    Frits
    Kr Saurav
    Greenhorn

    Joined: Sep 11, 2007
    Posts: 10
    Hi Frits,

    Thanks for replying. I just checked your notes and got the point. However I saw that your example uses dependency injection in the remote client.

    So when you say
    Dependency injection doesn't work when another server is involved. You will have to use the JNDI lookup (with JNDI-properties pointing at the remote server).


    Another server here means a server of different container type or just another instance of the same server(say another domain of a weblogic server).

    For your example app1.ear and app2.ear, are they in same server(JVM) or they can be in different JVM's without need for a change in remote client(say JNDI lookup against DI)

    Regards,
    Saurav
    Frits Walraven
    Creator of Enthuware JWS+ V6
    Bartender

    Joined: Apr 07, 2010
    Posts: 1734
        
      25

    Hi Saurav,

    Kr Saurav wrote:Hi Frits,
    Another server here means a server of different container type or just another instance of the same server(say another domain of a weblogic server).

    The EJB-specs require dependency injection of an EJB to work within one EJB-container. This means that DI of an EJB in another container, whether or not it is another instance of the same container-provider, is not required. It doesn't mean that it won't be supported by EJB-container providers. JBoss has a simple way of injecting an EJB from one container into another, see this blog.

    Regards,
    Frits
    Kr Saurav
    Greenhorn

    Joined: Sep 11, 2007
    Posts: 10

    Thanks Frits.

    Regards,
    Saurav
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Doubts about EJB local client view