On Sep 5, 2009, at 9:31 AM, Mho wrote:
To demonstrate this problem I have created a simple ear file that
looks like
this:
http://www.nabble.com/file/p25310121/aif6_ear.jpg
ext is a web app with a servlet "Agent" that just tries to talk to a
session
bean that is in an EJB called "service".
So I load up the ext.war file and also aif6.ear file in Tomcat and
restart
Tomcat.
( Note: I need to load the war file separately because Catalina
looks for
the document root for web app in /ext. Naturally when the EAR file is
expanded the document root is in /aif6/ext and Catalina throws an
exception
saying it cant find the web app. To make it happy I have to put the
war file
in the webapp directory. -- that is another problem that I will have
to fix
-- I am not sure this is related to the problem I am asking about in
this
email if anyone has a suggestion I will be grateful)
I think loading up the webapp separately is causing the problem.
Timing the loading of a separate webapp that has a reference to an ejb
jar inside a separate ear is not something that will be reliable.
The concept of the ear is that all the items are inside the ear and
that's how ordering is guaranteed.
All is not lost, however, there is a far easier approach. OpenEJB
supports putting ejb jar files *inside* the war file under WEB-INF/
lib/ or ejb classes under WEB-INF/classes/, more or less turning the
war as a sort of ear file. We call this Collapsed EAR:
http://openejb.apache.org/collapsed-ear.html
Note where it says in that document "Not quite J2EE", that is actually
changing. This functionality of OpenEJB is being added to the EJB 3.1
specification along with the Embedded EJB Container support that
OpenEJB does. So putting ejbs inside a war file will be a standard
thing in Java EE 6.
Hope that helps!
-David