3 Replies Latest reply: Jul 26, 2012 7:15 PM by wolfch RSS

Deployment Order With Spring

jbossadmin_007 Newbie

I am trying to specify deployment order inside an EAR (JBoss 5.1.0). The EAR contains a WAR, JARs, and Spring artifacts (.Spring archives). I list the .EAR file modules inside the /myEar.ear/META-INF/application.xml file. Then I place "<module-order>strict</module-order>" inside the /myEar.ear/META-INF/jboss-app.xml file. JBoss will then deploy the .EAR contents in the order specified in the application.xml. This works with the WARs and JARs; however, when I put Spring artifacts inside the .EAR, JBoss doesnt adhere to the "<module-order>strict</module-order>". Is there something special I need to do with Spring archives. How do you specify order with .Spring, WARs, and JARs inside an EAR?

  • 1. Re: Deployment Order With Spring
    mrjb Newbie

    *bump*

     

    I am also interested in how to solve this. I would suspect I have a pretty basic use case, using JBoss 7.1.1, Snowdrop 2.0.2 and Spring 3.1.1. My application in it's simplest form looks like this:

     

    myapp.ear
    |
    +- META-INF
    |  |
    |  +- MANIFEST.MF
    |  +- application.xml
    |
    +- lib
    |  |

    |  +- spring-3.1.1-jars.jar

    |  +- other-jars.jar

    |

    +- myapp.spring

    +- myapp.war

     

    My .war has a beanRefContext.xml that is trying to lookup the JNDI name that the SpringDeployer should have registered, which fails because the JNDI name is not found. There is also some randomness attached to this because for a while it did actually work, the JNDI name was found and deployment continued. I then copied some .jars on the JBoss servers, which I suspect might have modified their timestamps or something similar, in case that's one of the factors for deciding deployment order, and after that it has stopped working.

     

    My application.xml file looks like this:


    <application>

      (...)

      <initialize-in-order>true</initialize-in-order>

      <module>

        <java>./myapp.spring</java>

      </module>

      <module>

        <web>

          <web-uri>myapp.war</web-uri>

          <context-root>myapp</context-root>

        </web>

      </module>

    </...>

     

     

    I can't managed to get this working... My company is using JBoss 4.2 and there it is working fine, but we are figuring it's time to upgrade. I don't really need to keep the same deployment structure either it's just that I want a main Spring context to be deployed that other WAR's (and also MDB's) can access.

     

    Any ideas?

  • 2. Re: Deployment Order With Spring
    mrjb Newbie

    Well, my workaround right now is adding a Thread.sleep() to the constructor of a subclassed ContextLoaderListener, defined in the web.xml. It will wait until the spring context has been registered in the JNDI... Very ugly hack, but it works fine for now.

  • 3. Re: Deployment Order With Spring
    wolfch Newbie

    This may or may not help, but in my case, I had some Spring-configured object which depended on JNDI.  What I did was delay the deployment of the whole spring-deployer before the bean which implements JNDI naming.  JBoss does have a <depends/> tag for stating dependency on a service, but that's for the mbean schema, besides, I suppose that service names, themselves depend on the Naming service.  In any case, the deployment schema also has <depends/>, but unlike the mbean schema, the deployment schema's "depends" refers to bean names, rather then service names. So I modified the spring-deployer deployment descriptor (spring-deployer/META-INF/spring-deployers-jboss-beans.xml)  such that it's two bean declarations are:

     

        <bean name="SpringParserDeployer" class="org.jboss.spring.deployers.vfs3.SpringParserDeployer">

          <depends>NamingService</depends>

        </bean>

     

        <bean name="ApplicationContextDeployer" class="org.jboss.spring.deployers.ApplicationContextDeployer">

          <depends>NamingService</depends>

        </bean>