在JBOSS中升级Hibernate版本 [英] Upgrade Hibernate version in JBOSS

查看:192
本文介绍了在JBOSS中升级Hibernate版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力在我的EAR中发布我自己的Hibernate版本(而不是JBoss默认带来的版本)。

I am having a hard time when trying to ship inside my EAR my own version of Hibernate (and not the one that JBoss brings by default).

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

Then I made my deployment "scoped" by including in the EAR a jboss-app.xml file containing the following:

<jboss-app>
  <loader-repository> 
  com.example:archive=unique-archive-name 
     <loader-repository-config> 
     java2ParentDelegation=false 
     </loader-repository-config> 
  </loader-repository>
</jboss-app>

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

And, as usual, I declare my persistence provider in the persistence unit to be Hibernate, as follows:

<persistence>
   <persistence-unit name="myapp">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
   ...

但是,最糟糕的情况发生了。在部署时,服务器在尝试从 org.hibernate.ejb.HibernatePersistence 转换为JPA接口 javax.persistence.spi.PersistenceProvider 时会引发ClassCastException(这是一种威胁通过HibernatePersistence)。

But then, the worst happens. On deployment, the server throws a ClassCastException when it tries to cast from org.hibernate.ejb.HibernatePersistence to the JPA interface javax.persistence.spi.PersistenceProvider (which IS implimented by HibernatePersistence).

这是一种WEIRD,因为我也在我的EAR中运送JPA API,因此,鉴于EAR的类优先于那些JBoss,从HibernatePersistence转换为PersistenceProvider时应该没有问题,因为它们应该在同一个类加载器上。

This is kind of WEIRD, because I am shipping the JPA API also in my EAR, so, given that the classes of the EAR have priority to those of JBoss, it should have no problem when casting from HibernatePersistence to PersistenceProvider, since they "should be" on the same class loader.

如果我不发运我自己的JPA API,然后当JBoss试图找到一些JPA类时,部署失败并带有ClassNotFoundException。

If I don't ship my own JPA API, then the deployment fails with a ClassNotFoundException when JBoss tries to find some JPA class.

有关为什么这个转换失败的任何想法?

Any idea on why is this casting failing?

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

I am using JBoss 5.1.0, and trying to use Hibernate 3.5.6.Final. The JPA API version is the one imported transitively by the menctioned Hibernate version.

推荐答案

您可以尝试通过耳朵打开课程范围部署。对于JBoss 5.x编辑:

You could try turning on class scoping via the ear deployer. For JBoss 5.x edit:

jboss / server / [configuration] /deployers/ear-deployer-jboss-beans.xml

jboss/server/[configuration]/deployers/ear-deployer-jboss-beans.xml

并更改:

   <bean name="EARClassLoaderDeployer" class="org.jboss.deployment.EarClassLoaderDeployer">
      <property name="isolated">false</property>
   </bean>

设置隔离为真。

这篇关于在JBOSS中升级Hibernate版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆