[jboss-user] [JBoss/Spring Integration] - Chicken-Egg with PersistenceAnnotationBeanPostProcessor
do-not-reply at jboss.com
Tue Jul 15 13:53:58 EDT 2008
I have been trying to set-up a PersistenceAnnotationBeanPostProcessor using "vanilla" JNDI lookups to leverage all of the configuration we already have in JBoss (e.g., persistence.xml, JPA entites, etc.) I have run into what seems to be a chicken-egg issue with the ordering of the Spring-JBoss Deployer.
If I use something like the following in an application context loaded by the deployer:
| <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" lazy-init="true">
| <property name="persistenceUnits">
| <entry key="foo" value="java:/persistence-units/foo"/>
And specifically instruct JBoss to expose its EJB3 EntityManagerFactory via the following in persistence.xml:
| <persistence-unit name="foo">
| <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
| <property name="jboss.entity.manager.factory.jndi.name" value="java:/persistence-units/foo"/>
I get a javax.naming.NamingException (unable to find 'java:/persistence-units/foo"). Looking at the logs, I noticed that the Spring-JBoss Deployer deploys *before* the EJB-managed JPA entities are loaded and then bound to JNDI by the EJB3 deployer.
So... I thought I would control the ordering of the Spring-JBoss MBean by tinkering with jboss-service.xml:
This allowed the EJB entities to be loaded and bound to JNDI before the application context beans were loaded, and all was well. Except that must have done something else somewhere because the WAR stopped loading properly.
Is there a simple way to use PersistenceAnnotationBeanPostProcessor and JNDI to allow for multiple persistence units already initialized by the EJB3 deployer in JBoss?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4164567#4164567
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4164567
More information about the jboss-user