As part of the upgrade from JBoss 4.0.4 to 5.1, I am trying to run a WAR to deploy after a successful EAR deployment. JBoss 5.x does not support PrefixDeploymentSorter , as well as 4.x, which means that I have to use <depend> in WAR jboss-web.xml.
It seems that I cannot depend on the EAR itself , so I choose the last deployed EJB. This EJB provides the JNDI entry that WAR needs.
Here is the EJB when it is deployed when the WAR is not in the deployment directory:
2010-03-25 10:47:30,348 INFO [org.jboss.ejb3.session.SessionSpecContainer] (main) Starting jboss.j2ee:ear=my-ear.ear,jar=mypackage-ejb.jar,name=MyFacadeBean,service=EJB3 2010-03-25 10:47:30,350 INFO [org.jboss.ejb3.EJBContainer] (main) STARTED EJB: my.package.MyFacadeBean ejbName: MyFacadeBean 2010-03-25 10:47:30,371 INFO [org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] (main) Binding the following Entries in Global JNDI: my/MyFacade/local - EJB3.x Default Local Business Interface my-ear/MyFacadeBean/local-my.package.MyFacade - EJB3.x Local Business Interface
And here the fragment depends on jboss-web.xml:
<depends>jboss.j2ee:ear=my-ear.ear,jar=mypackage-ejb.jar,name=MyFacadeBean,service=EJB3</depends>
My problem: WAR starts deploying right after "STARTED EJB:", that is, before MyFacadeBean is bound to the JNDI, which causes the bean deployment to fail:
2010-03-25 10:47:39,068 ERROR [my.facade.FacadeFactory] (main) MyFacade not bound 2010-03-25 10:47:39,069 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[my.host.no].[/]] (main) StandardWrapper.Throwable java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:164) at my.freemarker.servlet.FreemarkerController.setupPojoServiceFactory(FreemarkerController.java:621) [...] Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: MyFacade not bound at my.facade.FacadeFactory.getFacade(FacadeFactory.java:61)
After WAR has completed its deployment, MyFacade joyfully (mockingly?) Continues the deployment and associates the JNDI records.
If I warmly deploy WAR after deploying an EAR, everything works as intended.
I even thought that depending on the dummy EJB in the EAR, and using <module-order> strict </ module-order> in jboss-app.xml to make it load as the last module. But alas, JBoss 5.x also does not support this . Doh!
Is there a way to depend on the JNDI record itself? Are there other ways to solve this problem?