aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Question about resuable EJB's and where to deploy them. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Question about resuable EJB Watch "Question about resuable EJB New topic
Author

Question about resuable EJB's and where to deploy them.

SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
I'm currently using Weblogic 6.1 for a number of different applications that we are developing. There is certain functionality that I have found to be common in all of the applications, such as as "log in" and "employee searching." We have created session EJB's accessing DAO's to represent this common functionality, but since these EJB's are not specific to any application, where should they be deployed? I dont want to duplicate the EJB jars in each separate web deployment of different applications. I would like to create a web application which serves the single purpose of making these common EJB's available to all other applications running on the app server. What do you guys think?
SAF
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
The "gold standard" for EAR files are that they are self-contained. In fact all of the EJB Jars that you need in an EAR should be stored inside the EAR. The reason for this is that the problem would be that you might get version skew if different apps built on top of these EJB's tried to use them and the version of the shared EJB changed underneath the application.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
When you say that the EJB jars should be stored in the EAR file, do you mean they should physically exist at the EAR root level? I can see why this makes sense because any WAR file contained within the EAR file would have centralized access to the EJB's available.
But does the CLASSPATH of a WAR contained within an EAR need to be modified if, say, a servlet in the WAR, makes a reference to an EJB?
Thanks for the info Kyle.
SAF
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16134
    
  21

This is trickier than it sounds. In WebLogic 5, the EJBs were global to the server, WLS 6, however, favors the EAR approach.
Kyle's right about the version creep (as seen by Windows "DLL Hell"). Of course, the knife cuts both ways if you have key business logic that must be kept current and in sync across multiple apps.
One possible resolution to that might be to use the EJBs as an interface and have them defer to a common resource, though that's really just pushing the problem a layer deeper.


Customer surveys are for companies who didn't pay proper attention to begin with.
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Originally posted by SAFROLE YUTANI:
When you say that the EJB jars should be stored in the EAR file, do you mean they should physically exist at the EAR root level? I can see why this makes sense because any WAR file contained within the EAR file would have centralized access to the EJB's available.
But does the CLASSPATH of a WAR contained within an EAR need to be modified if, say, a servlet in the WAR, makes a reference to an EJB?
Thanks for the info Kyle.
SAF

Well, it depends on your app server. Some app servers have a feature whereby you can say that all of the WARS in an EAR (and all of the EJB-JARs in an EAR) automatically see each other. If that's not true for your app server (or you turn it off) then another option is to add a reference to the other JAR file in the MANIFEST.MF file of your WAR or JAR file. For instance, if your "utility" EJBs were in a JAR file named "utility.jar", then just add a line to the manifest of your WARs saying
Class-Path: utility.jar
Kyle
SAFROLE YUTANI
Ranch Hand

Joined: Jul 06, 2001
Posts: 257
Great. Thanks for the info Kyle!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about resuable EJB's and where to deploy them.