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.
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.
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.
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.
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
I think, therefore I exist -- Rene Descartes
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop