4 Replies Latest reply: Jul 27, 2011 2:58 AM by Marcus Ilgner RSS

JBoss 6 + Snowdrop 2: order of JPA & Spring deployers

Marcus Ilgner Newbie

Hello everyone,

 

I'm trying to run an application in JBoss AS 6 which contains both a persistence.xml which I would like to be started by JBoss, then afterwards a Spring application context is initialized which uses the previously defined persistence unit.

This worked fine in JBoss AS 5.1.0.GA using Snowdrop Spring Deployer from Snowdrop 1.1.0. But when I try to run it in JBoss AS 6.0.0.Final, the spring.deployer runs before the EJB/JPA deployer, resulting in an error because my Spring application cannot find the EntityManagerFactory.

 

Is there a way to change the order the deployers are started? I found one subject mentioning that there should be some "-service.xml" for the Spring deployer where one could supposedly use some kind of setRelativeOrder statement to influence the deployer chain but as that was referring to JBoss AS 4, I guess it is probably outdated anyway.

 

All the best

Marcus

  • 1. JBoss 6 + Snowdrop 2: order of JPA & Spring deployers
    Marius Bogoevici Expert

    Hi Marcus,

     

    The file you are asking for is $JBOSS_HOME/server/$PROFILE/deployers/spring.deployer/META-INF/spring-deployers-jboss-beans.xml .

    (or spring.deployer/META-INF/spring-deployers-jboss-beans.xml in the distribution).

     

    You can set the relativeOrder property on the ApplicationContextDeployer bean - lower values have higher precedence.

     

    Marius

  • 2. JBoss 6 + Snowdrop 2: order of JPA & Spring deployers
    Marcus Ilgner Newbie

    Hi Marius,

     

    thank you very much for the tip. But even if I modify the file to read

    [code]

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

              <property name="relativeOrder">2147483647</property>

    </bean>

    [/code]

     

    It still starts before the PersistenceUnit deployment. If I comment this bean, JPA starts as expected. I'm not sure if BeanFactoryDeployer could help me but uncommenting it doesn't seem to do anything.

    Are there any other dependency mechanisms that could block PU deployment from running?

     

    Best regards

    Marcus

  • 3. Re: JBoss 6 + Snowdrop 2: order of JPA & Spring deployers
    James Fluckiger Newbie

    Hello,

     

    I am encountering the same problem now -- an application that uses JPA and Spring works in JBoss 5.1, but fails to load under JBoss 6.0.0.  Under 5.1, the first thing that happens when the app deploys is the loading of the Perssitence unit from persistence.xml

     

    In JBoss 6.0, on the other hand, the application context loads first, and this fails because it depends on the persistence unit.

    I tried the "relativeOrder" modification, as illustrated by Marcus in this thread, but that didn't seem to make any difference.

     

    Is there any more information on this issue?

     

    Thanks,

    Jim

  • 4. Re: JBoss 6 + Snowdrop 2: order of JPA & Spring deployers
    Marcus Ilgner Newbie

    Well, I haven't spend time on application server integration lately, as my application is neither a web-app nor so complex that it doesn't work with a standalone application context...

    And while I couldn't get it to work on JBoss AS 6, I'm wondering if maybe JBoss AS 7 would be an option for you? Marius' latest blog post suggests that Spring applications work very well on it.

    http://community.jboss.org/blogs/mariusb/2011/07/13/spring-and-jboss-as7-part-1-getting-started

     

    All the best

    Marcus