Sometimes the order of deployed units, in an Enterprise application matters. For example, if you are deploying an EAR which is made up of a WEB application an EJB, it can be necessary that the EJB application is deployed at first.

A typical scenario is a Web application uses ServletContextListeners. If the ServletContextListener tries to access the EJB, as soon as the Web component is deployed, a NamingException might be the outcome of it, because the EJB hasn't been still bound in the JNDI.

The quick fix to it is adding a ContextComparator in conf\bootstrap\deployers.xml file:  

<bean name="topContextComparator">
  <constructor factoryClass="org.jboss.system.deployers.LegacyDeploymentContextComparator" factoryMethod="getInstance"/>
  <property name="suffixOrder" class="java.util.Map">
    <map keyClass="java.lang.String" valueClass="java.lang.Integer">

This will ensure that your Web application is loaded after the EJB modules.


Related articles available on

How to configure JBoss to disable hot deployment ?

On JBoss AS 7 and WildFly the default rule is that archived appli

How do I make sure my MBean is deployed after my EJB ?

  If your MBean is dependant on another resource, supposing cont

How do I change the default lib directory in an ear file?

  Supposing you have an Enterprise application which has been pa

How to let JBoss deploy an application after other apps?

  If you are running JBoss AS 7 or WildFly check the following t

How to deploy an application temporarly with JBoss ?

One way to do it, is using the jboss.system:service=MainDeployer

How to add a custom JBoss archive in an Ear ?

JBoss custom archives (like .sar or .har) are not recognized by t