This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes ejb/war deployment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejb/war deployment" Watch "ejb/war deployment" New topic
Author

ejb/war deployment

Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 257
Hello. If anybody has a minute...I've tried to create a war file that includes jsps, regular javabeans, and three ejbs and deployed it to the j2ee server. What I found was that while testing the app, my session attributes kept clearing to null. As a followup test, I removed the ejb stuff and deployed the jsps and javabeans on their own in a new war and had no problems with session attributes.

Is it general practice to deploy ejb in it's own web archive or what is the general strategy for deploying apps that include ejb? My suspicion is that once deployed, the server keeps compiling the ejb classes over and over and this somehow messes with the session..but not sure yet. THank you for reading...I'll still mess with it and let you know what I can come up with. Maybe this has something to do with that RMI stuff. Can a JNDI lookup be made to another application..say I deploy the jsp/javabeans in one app and the ejb in another? Thank you again for reading this.
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Hi Tom,


Is it general practice to deploy ejb in it's own web archive or what is the general strategy for deploying apps that include ejb?

EJBs don�t get packed within the war and I have no idea what would be the consequences of such packing, since I never tried. I would only suppose that it simply doesn�t work. EJBs could be deployed either individually in their own jar, or grouping more EJBs in a common jar and deploy the jar individually. This however has the limitation that each EJB it�s loaded by its own individual classloader and therefore they cannot communicate via local interfaces. A better approach though is to pack the war and ejb-jars in a unique ear file. The container knows how to create related classloaders that load the classes and allows components located in one module to access components located into another module in the most optimal way.

Can a JNDI lookup be made to another application..say I deploy the jsp/javabeans in one app and the ejb in another?

Yes this is possible as well, but again you have different unrelated classloaders and therefore your servlets/jsps will always make expensive RMI calls I order to access the ejbs.
Regards.


I think, therefore I exist -- Rene Descartes
Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 257
Hi Valentin. THank you again. So the optimal approach you are suggesting is...

1. packing the ejbs into one jar

2. packing the jsp, javabeans, etc into one war

3. packing the ejb jar and the war into one ear

4. deploy the ear to the server?
[ April 13, 2005: Message edited by: Tom Griffith ]
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Mainly this is what I�m saying. However 1 might be little bit trickier, because you can either pack each bean in its own jar, or pack all ejbs within a unique jar, or group ejbs in different jars. The last one is a common packing pattern when you pack entity ejbs. Usually beans that are related will get packed together. Hence every jar file will contain the whole graph of entity ejbs. However from the container standpoint it is no difference, as long as all components are packed in the same ear.
Regards.
Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 257
Valentin, is there a way to create ear from the command line? I keep coming across tools that us eit but like jar and war, I always preferred the command line. It looks as though the ear will require another descriptor file of some sort as well. I've been looking all over but it seems like anything I find for creating ear uses some server specific module. Thank you again for your time and for readng this or whatever.
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
The most common way to build an ear is to use ant. The most sample but manually way of doing it is to create a usual jar and rename it ear (using the java jar tool). On Windows is even simpler than that: use WinZip to create a regular zip file and rename it ear as well. And you are right; the ear will required its own deployment descriptor application.xml located under the META-INF folder. This mainly will describe the modules packed within your ear.
Here there is an example (this ear contains 3 ejbs and 2 web apps):

And by the way Tom, you're very welcome
 
jQuery in Action, 2nd edition
 
subject: ejb/war deployment
 
Similar Threads
Deserialization problem - InvalidClass w/ negative serialVersionUid for local class
linking webapp with ejb in ear
Isolation of EARs (and EJB3)
Deploying Jar inside WebSphere5
Access deployed archive contents