JBoss AS7 Automatically Loading JPA

我只是一个虾纸丫 提交于 2020-01-02 04:51:09

问题


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.


回答1:


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 :-)




回答2:


I have find solution for that:

http://mariemjabloun.blogspot.com/2014/05/integrating-spring-4-and-jboss-eap-62.html

http://mariemjabloun.blogspot.com/2014/03/use-jboss-jpa-21-and-hibernate-43-on.html



来源:https://stackoverflow.com/questions/10231575/jboss-as7-automatically-loading-jpa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!