-
1. Re: Chicken-Egg with PersistenceAnnotationBeanPostProcessor
saish Jul 15, 2008 2:01 PM (in response to saish)Realized I was somewhat think in my snippit, "the WAR stopped working properly". What happened there was that beanRefContext.xml could no longer locate the ApplicationContext mounted by the Spring Deployer. (JNDI javax.naming.NamingException). So, I attempted to add a dependency within the jboss-web.deployer (to have a dependency on the Spring deployer), and at that point, the WAR would not load. There were no errors, but localhost:8080 never returned anything.
So, in an ideal world:
1. Load EJB JPA entities managed by JBoss and bind EntityManagerFactory to JNDI.
2. Load the EAR ApplicationContext and bind to JNDI via Spring JBoss Deployer
3. Finally load the WAR so that context.ear in beanRefContext.xml finds the JNDI ApplicationContext.
Saish -
2. Re: Chicken-Egg with PersistenceAnnotationBeanPostProcessor
alesj Jul 15, 2008 4:22 PM (in response to saish)Since you're probably talking about JBossAS4.x, this is what you can do:
Default deployers order:<!-- Statically set one or more enhanced suffix orders, independent of the value proposed by subdeployers. Some deployers may also allow the suffixes/orders to be set locally, so that's preferable too. For reference, this is the list of enhanced suffixes likely to be set by deployers (it may not be completely up-to-date, or there can be user-defined deployers). 050:.deployer,050:-deployer.xml,100:.aop,100:-aop.xml,150:.sar,150:-service.xml,200:.beans,250:.rar,300:-ds.xml,350:.har,400:.jar,400:.ejb3,400:.par,500:.war,600:.wsr,650:.ear,700:.jar,750:.zip,800:.bsh,900:.last Until we resolve some startup issues, we'll setup some static enhanced suffix orders bellow and leave the rest of the suffixes contributed dynamically by registering deployers. --> <descriptors> <value value="250:.rar,300:-ds.xml,400:.jar,500:.war,550:.jse,650:.ear,800:.bsh"/> </descriptors>
SpringDeployer defines #350:public SpringDeployer() { initializeMainDeployer(); } protected void initializeMainDeployer() { setSuffixes(new String[]{".spring", "-spring.xml"}); setRelativeOrder(350); //after -ds, before ejb3 }
Just change that property in SpringDeployer's -service.xml and you should be fine. ;-) -
3. Re: Chicken-Egg with PersistenceAnnotationBeanPostProcessor
saish Jul 17, 2008 10:51 AM (in response to saish)Thanks so much Ales! That is exactly what I was looking for.
As an aside, I did manage to get things set up "manually" by using LocalContainerEntityManagerFactoryBean. The "trick" in that instance was to set up one for each of my persistence units. I also got hung up by using 'name' rather than 'unitName' for @PersistenceContext injection. (Writing this in the hope of saving others pain, as none of the examples I could find set up more than one PU).
The downside to this is that JBoss scans persistence.xml and maps all the JPA entity beans. Then, Spring does the same thing. A bit inefficient, which is why I wanted to simply use JNDI to grab the EMF's that JBoss already bound.
That ordering snippit should do the trick. Thanks again!
Saish