在JBOSS中升级Hibernate版本

Mr.*_*art 5 java jboss hibernate classloader java-ee

我试图在我的EAR中发布我自己的Hibernate版本时遇到困难(而不是JBoss默认带来的版本).

然后我通过在EAR中包含一个包含以下内容的jboss-app.xml文件来使我的部署成为"作用域":

<jboss-app>
  <loader-repository> 
  com.example:archive=unique-archive-name 
     <loader-repository-config> 
     java2ParentDelegation=false 
     </loader-repository-config> 
  </loader-repository>
</jboss-app>
Run Code Online (Sandbox Code Playgroud)

并且,像往常一样,我将持久性单元中的持久性提供程序声明为Hibernate,如下所示:

<persistence>
   <persistence-unit name="myapp">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
   ...
Run Code Online (Sandbox Code Playgroud)

但是,最糟糕的情况发生了.在部署时,服务器在尝试从org.hibernate.ejb.HibernatePersistence转换为JPA接口javax.persistence.spi.PersistenceProvider(由HibernatePersistence表示)时抛出ClassCastException .

这有点像WEIRD,因为我也在我的EAR中发布JPA API,因此,鉴于EAR的类优先于JBoss的类,从HibernatePersistence转换为PersistenceProvider时应该没有问题,因为它们"应该"是"在同一个班级装载机上.

如果我没有发布自己的JPA API,那么当JBoss试图找到一些JPA类时,部署会因ClassNotFoundException而失败.

任何关于为什么这个演员失败的想法?

我正在使用JBoss 5.1.0,并尝试使用Hibernate 3.5.6.Final.JPA API版本是由被提取的Hibernate版本传递的版本.

Luc*_*eni 1

您也包含了 hibernate-entitymanager.jar 吗?

否则,您可以尝试将 common/lib 中的 hibernate core jar 替换为 3.5.6 版本。