aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Expose EJBs within .war to other modules within the same EAR 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 "Expose EJBs within .war to other modules within the same EAR" Watch "Expose EJBs within .war to other modules within the same EAR" New topic
Author

Expose EJBs within .war to other modules within the same EAR

Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Hi,
I have the following excerpts from EJB3.1 specifications document and questions-

page 590
Applications needing access to the local client view of an enterprise bean from a different module in the same application should use an ejb-jar file to define the enterprise bean that exposes the local client view.


Okay, I understand we should have WEB-INF/ejb-jar.xml to expose local client view(including no-interface client view). Can I see some sample xml fragment of how this can be done? Also, imagine I have under WEB-INF/lib/<ejb-jar>.jar file which has in itself META-INF/ejb-jar.xml. Can I still expose my local client view(including no-interface client view) without defining WEB-INF/ejb-jar.xml?


page 593
If the by-reference approach is used, the ejb-jarfile or .war file producer does not duplicate the content of the ejb-client JAR file in the ejb-jar fileor .war file, but instead uses a Manifest Class-Path entry in the ejb-jar file or .war file to specify that the ejb-jar file or .war file depends on the ejb-client JAR at runtime. The use of the Class-Path entries in JAR files and .war files is explained in the Java EE Platform specification [12].


Why does a Bean Provider/Application Assembler want to create ejb client jar file "within" the EAR file/WAR file? It has to be generated outside and shared to the clients. Also, why do .war or ejb-jar file want to depend on ejb client jar file by referring in my MANIFEST.MF's Class-Path entry? ejb client jar has nothing to do with the actual ejb jar file but it is needed to clients who call these EJBs. I'm sure, spec doesn't lie, may be my interpretation is wrong?

Thanks,
Naren


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1733
    
  25

The way I read this:
The local client view(including the no-interface view) of an enterprise bean component defined within a .war file is only required to be accessible to components within the same .war file. Applications needing access to the local client view of an enterprise bean from a different module in the same application should use an ejb-jar file to define the enterprise bean that exposes the local client view.

is that if you want to expose a local view of the EJB packaged in the .war file you should have a setup like this (ejb packaged in an ejb-jar inside WEB-INF/lib, no EJB classes inside WEB-INF/classes). Note that having an ejb-jar file inside the lib directory is logically the same as having the ejb classes in the WEB-INF/classes directory of the .war file.


Naren Chivukula wrote: Why does a Bean Provider/Application Assembler want to create ejb client jar file "within" the EAR file/WAR file? It has to be generated outside and shared to the clients

It can create an ejb client jar inside the lib directory of the .war file:

The MyEJBClient.jar can than be used for local clients outside the .war file as well (the .ear file might consist of a couple of EJB modules all using the same MyEJB). Just to get an idea you might want to have a look at my graph in chapter 10.2.1.

Regards,
Frits
Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Thanks Frits. A second read-through makes sense.

 
 
subject: Expose EJBs within .war to other modules within the same EAR