如何在JBoss AS 7.1.3中添加更新版本的Hibernate [英] How to add a newer version of Hibernate in JBoss AS 7.1.3

查看:90
本文介绍了如何在JBoss AS 7.1.3中添加更新版本的Hibernate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了JBoss AS 7.1.3(没有机会改变它),它随Hibernate 4.1.6一起提供。由于在这样的版本中有一个错误(没有可用的解决方法),我必须更新我的应用程序以使用Hibernate 5.1。

由于这发生在特定的应用程序中,必须接收更新版本的Hibernate,同一服务器中的其他应用程序必须继续使用现有的Hibernate版本。



如何:


  1. 为现有的JBoss AS 7.1安装添加一个新的Hibernate版本?
  2. 配置我的Eclipse Maven项目以使用该Hibernate版本?

TIA!

Update1



这是我当前的 module.xml 文件,位于 ... \jboss-as-7.1.3.Final \modules\org\hibernate\5.1.10.Final

 < module xmlns =urn:jboss:module:1.1name =org.hibernate:5.1.10.Final> 
<资源>
< resource-root path =hibernate-core-5.1.10.Final.jar/>
< resource-root path =hibernate-entitymanager-5.1.10.Final.jar/>
< resource-root path =hibernate-infinispan-5.1.10.Final.jar/>
<! - 在此处插入资源 - >
< /资源>

<依赖关系>
< module name =asm.asm/>
< module name =javax.api/>
< module name =javax.persistence.api/>
< module name =javax.transaction.api/>
< module name =javax.validation.api/>
< module name =org.antlr/>
< module name =org.apache.commons.collections/>
< module name =org.dom4j/>
< module name =org.infinispanoptional =true/>
< module name =org.javassist/>
< module name =org.jboss.as.jpa.hibernateslot =4optional =true/>
< module name =org.jboss.logging/>
< module name =org.hibernate.enversservices =importoptional =true/>
< module name =org.hibernate.commons-annotations/>
< /依赖关系>
< / module>


解决方案

您可以控制 JBoss的部署-structure.xml 。它应该看起来像这样(请阅读您的jboss版本关于确切配置参数的文档):

 < jboss- deployment-structure xmlns =urn:jboss:deployment-structure:1.2xmlns:xsi =http://www.w3.org/2001/XMLSchema-instance> 
< deployment>
<排除项>
< module name =org.hibernateslot =main/>
< /排除>
<依赖关系>
< module name =org.hibernateslot =5.1.10.Final/>
< /依赖关系>
< / deployment>
< / jboss-deployment-structure>

您可能还需要在 persistence.xml中添加以下属性

 < property name =jboss.as.jpa.providerModulevalue =org。冬眠:5.1.10.Final/> 

另外,创建一个新模块并复制您想要使用的Hibernate版本所需的jar; 这里是关于AS7中类加载的更多细节。

I have an installation of JBoss AS 7.1.3 (not a chance to change that) that comes with Hibernate 4.1.6. Due to a bug in such a version (no workarounds available) I have to update my application to use Hibernate 5.1.

Since this happens in a particular application, only that one has to receive the newer version of Hibernate, other applications in the same server must continue to use the already present Hibernate version.

How to:

  1. Add a new Hibernate version to an existing JBoss AS 7.1 installation?
  2. Configure my Eclipse Maven project to use that Hibernate version?

TIA!

Update1

This is my current module.xml file, located at ...\jboss-as-7.1.3.Final\modules\org\hibernate\5.1.10.Final:

<module xmlns="urn:jboss:module:1.1" name="org.hibernate:5.1.10.Final">
    <resources>
        <resource-root path="hibernate-core-5.1.10.Final.jar"/>
        <resource-root path="hibernate-entitymanager-5.1.10.Final.jar"/>
        <resource-root path="hibernate-infinispan-5.1.10.Final.jar"/>
        <!-- Insert resources here -->
    </resources>

    <dependencies>
        <module name="asm.asm"/>
        <module name="javax.api"/>
        <module name="javax.persistence.api"/>
        <module name="javax.transaction.api"/>
        <module name="javax.validation.api"/>
        <module name="org.antlr"/>
        <module name="org.apache.commons.collections"/>
        <module name="org.dom4j"/>
        <module name="org.infinispan" optional="true"/>
        <module name="org.javassist"/>
        <module name="org.jboss.as.jpa.hibernate" slot="4" optional="true"/>
        <module name="org.jboss.logging"/>
        <module name="org.hibernate.envers" services="import" optional="true"/>
        <module name="org.hibernate.commons-annotations"/>
    </dependencies>
</module>

解决方案

You can control class loading in the jboss-deployment-structure.xml. It should look something like this (please read the docs of your jboss version about the exact configuration parameters):

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <deployment>
        <exclusions>
            <module name="org.hibernate" slot="main" />
        </exclusions>
        <dependencies>
            <module name="org.hibernate" slot="5.1.10.Final" />
        </dependencies>
    </deployment>
</jboss-deployment-structure>

You may also need to add the following property in the persistence.xml:

<property name="jboss.as.jpa.providerModule" value="org.hibernate:5.1.10.Final"/>

Also, create a new module and copy the necessary jars for the Hibernate version you want to use; here are more details about class loading in AS7.

这篇关于如何在JBoss AS 7.1.3中添加更新版本的Hibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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