Configuring JBoss AS 7 deployment order

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

You can configure JBoss AS deployment order inside an EAR with a simple trick, here we will show how to do it!

If you are using application.xml 6.0 schema you have an handy element named initialize-in-order which, if set to true, initializes the modules in the same order they are listed. For example here the webapp.war will be initialized as first module of the ear:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  version="6" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd">
 
  <application-name>sampleapp</application-name>
  <initialize-in-order>true</initialize-in-order>
  <module>
    <web>
      <web-uri>webapp.war</web-uri>
      <context-root>test</context-root>
    </web>
  </module>
 
  <module>
    <ejb>core-ejb.jar</ejb>
  </module>

</application>

What if you need configuring the deployment order between two applications, say two EAR files ? then you can use jboss-deployment-structure.xml.  jboss-deployment-structure.xml is a JBoss specific deployment descriptor that can be used to control class loading in a fine grained manner. It should be placed in the top level deployment, in META-INF (or WEB-INF for web deployments).

For example, let's say you have app1.ear and app2.ear. Here we configured the deployment structure of app2.ear to depend on app1.ear, so that the former will be deployed first:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
   <deployment>
       <dependencies>
           <module name="deployment.app1.ear" />
       </dependencies>
   </deployment>
</jboss-deployment-structure>

Important! If you need to configure a dependency toward one or more EAR files, which are deployed separately, then you need to use jboss-all.xml file as follows:

<jboss umlns="urn:jboss:1.0">
    <jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">
        <dependency name="application1.ear" />
        <dependency name="application2.ear" />
    </jboss-deployment-dependencies>
</jboss>

 

Related articles available on mastertheboss.com

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

Follow us on Twitter