I have an application which uses JPA/Hibernate and Google Guice. Guice is bootstrapped in a ServletContextListener
and it sets up the EntityManagerFactory
itself.
The application works fine on Tomcat 7, but when I deploy to JBoss AS7 it fails because JBoss decides to automatically setup JPA prior to invoking my ServletContextListener
.
How can I get JBoss to not initialize JPA automatically and instead wait for my ServletContextListener
to do it?
Update
According to the link that James provided below:
During application deployment, JPA use is detected (e.g. persistence.xml or @PersistenceContext/Unit annotations) and injects Hibernate dependencies into the application deployment.
https://docs.jboss.org/author/display/AS71/JPA+Reference+Guide#JPAReferenceGuide-Introduction
I need to figure out how to disable this "auto-detect" feature.
Update #2
Container management of JPA can be disabled by adding the following property to the persistence.xml:
<property name="jboss.as.jpa.managed" value="false" />
According to this topic, as of February 2012 this functionality is only available in a nightly build.