title: How to order deployment of EJBs and JMS queue config in JBoss 5?
body: <p>I'm using JBoss [EAP] 5.0.0.GA and I have an EAR which contains an EJB jar that contains some MDBs which depend on the existence of the JMS queues that they use. When I configured the queues in <code>.../server/all/deploy/messaging/myqueues-service.xml</code> there was no problem. </p>
  
  <p>However, I wanted to configure the queues in the EAR file to avoid having to make changes to the JBoss config directly. No problem, I put my <code>myqueues-service.xml</code> file into the root of the EAR and added the reference to my <code>jboss-app.xml</code> as follows:</p>
  
  <pre><code>&lt;jboss-app&gt;
      &lt;module-order&gt;strict&lt;/module-order&gt;
      &lt;loader-repository&gt;
          seam.jboss.org:loader=my-ear.ear
      &lt;/loader-repository&gt;
      &lt;module&gt;
          &lt;service&gt;myqueues-service.xml&lt;/service&gt;
      &lt;/module&gt;
  &lt;/jboss-app&gt;
  </code></pre>
  
  <p>However, when I do that, JBoss loads the EJB jar (contained in my-ear.ear) first and then configures the JMS Queues afterwards. This results in errors when the MDB are loaded:</p>
  
  <pre><code>12:16:02,714 WARN  [JmsActivation] Failure in jms activation org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@13a59e .....
  javax.naming.NameNotFoundException: MyQueue not bound
  </code></pre>
  
  <p>It's not a huge problem, as later on the MDBs successfully reconnect to JMS:</p>
  
  <pre><code>12:16:12,698 INFO  [JmsActivation] Attempting to reconnect org.jboss.resource.adapter.jms.inflow.JmsActivationSpec@f91ad5
  12:16:12,823 INFO  [JmsActivation] Reconnected with messaging provider.
  </code></pre>
  
  <p>But I'd really like to avoid having any errors, and in order to do that I need a way to force JBoss to configure the JMS queues first, before loading the EJB jar. Is there any way to do this? For reference, here's the <code>application.xml</code> for the EAR:</p>
  
  <pre><code>&lt;application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5"&gt;
    &lt;display-name&gt;my-ear&lt;/display-name&gt;
    &lt;module&gt;
      &lt;ejb&gt;my-ejb.jar&lt;/ejb&gt;
    &lt;/module&gt;
    &lt;module&gt;
      &lt;web&gt;
        &lt;web-uri&gt;my.war&lt;/web-uri&gt;
        &lt;context-root&gt;myroot&lt;/context-root&gt;
      &lt;/web&gt;
    &lt;/module&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>Any suggestions appreciated.</p>