The Source for Java Technology Collaboration
User: Password:
Register | Login help    

Search

Online Books:
java.net on MarkMail:


GlassFish Migration: Java EE Module Loading Order (I)

Posted by sekhar on January 20, 2009 at 9:13 PM PST

Recently there has been some questions regarding order in which Java EE modules in a Java EE eneterprise applications. The order in which Java EE modules are loaded varies between Java EE application servers. So it is a migration issue issue. This is the first of my blogs on this topic. In this blog, I have highlighted some aspects of order of loading of Java EE modules packaged in a *single* ear file deployed on GlassFish V2.

In GlassFish V2, currently, the modules in an ear file are loaded in the following order: connector modules, ejb modules and then web modules. If there are multiple modules of same type, the order in which they are loaded is random.

One interesting use is that of a message driven bean, which upon receiving a request, invokes an ejb which is part of the same enterprise application (ear file). In this case, it might look there is an ordering constraint ( ejb must be loaded before message driven bean). However, that is not the case because Java EE 5 spec requires that all parts of the application are enabled and ready for service before any *user* requests are delivered to the application. Section EE.8.4,"Deployment" of Java EE 5 spec has the following requirement:

"In all cases, the deployment of a Java EE application must be complete before the container delivers requests to any of the application's components. When an application is started, the container must deliver requests to enterprise bean components immediately. Containers must deliver requests to web components and resource adapters only after initialization of the component has completed."

You can control the order of initialization of servlets in web application, using <load-on-startup> element. Servlets marked with lower integers are loaded before servlets marked with higher integers. Servlet Spec 2.5, section SRV.13.4 "Deployment Descriptor Diagram" specifies this precisely.

That is it for now. I will be back later with more info on this topic.

Related Topics >> Glassfish      
Comments
Comments are listed in date ascending order (oldest first)

What if your web application is in a war, and your ejbs are in an ear. In this case I think the war loads before the ear? Is there anyway around this? (i.e. to force the ear to load first). I have a war referencing ejbs in an EAR...on startup the annotated injection of the ejbs fails because the EAR has not yet bound them in JNDI.