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.
JBoss AS7 is a full Java EE server. That means that a JPA implementation comes bundled with it. In Tomcat you have to provide your own JPA implementation and are essentially running JPA like you would in Java SE.
I would recommend you read the JPA reference documentation for AS7.
You also get CDI so there is no real need for Guice. You could probably use Guice instead of CDI, but honestly I couldn't tell you how :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With