Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
SAFROLE YUTANI
Ranch Hand
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18218
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great. Thanks for the info Kyle!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic