使用Jboss EAP 6.1在代码中使用javax.persistence.JoinColumn.foreignKey批注时出错 [英] Error on using javax.persistence.JoinColumn.foreignKey annotation in code using Jboss EAP 6.1

查看:118
本文介绍了使用Jboss EAP 6.1在代码中使用javax.persistence.JoinColumn.foreignKey批注时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在代码中使用了javax.persistence.JoinColumn.foreignKey.使用WildFly服务器,该项目运行正常,但是当我使用Jboss EAP 6.1时,出现以下错误:

I am using javax.persistence.JoinColumn.foreignKey in my code. The project is working fine using WildFly server, but when I use Jboss EAP 6.1, it gives below error:

java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey; org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:2884) org.hibernate.cfg.AnnotationBinder.bindOneToOne(AnnotationBinder.java:3051) org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1839) org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:963) org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:796)

java.lang.NoSuchMethodError: javax.persistence.JoinColumn.foreignKey()Ljavax/persistence/ForeignKey; org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:2884) org.hibernate.cfg.AnnotationBinder.bindOneToOne(AnnotationBinder.java:3051) org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1839) org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:963) org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:796)

当我进一步调查该问题时,我发现JBoss Library不支持Join列.

When I further investigated the issue, I found that JBoss Library does not support Join columns.

但是,我的项目库支持Join列,因此我打算在代码中使用这些库.但是Jboos库似乎覆盖了类路径中的库.

However, my project library supports Join column and I intent to use these library in my code. But Jboos libraries seem to be overriding the libraries in the class path.

我尝试了jboss-deployment-structure.xml

<exclusions>
    <module name="javax.persistence.api"/>
    <module name="javaee.api"/> 
</exclusions> 

但是我遇到了错误

11:19:55,195错误[org.jboss.msc.service.fail](MSC服务线程1-7)MSC000001:无法启动服务 jboss.deployment.unit."myappl.war" .PARSE: 服务中的org.jboss.msc.service.StartException jboss.deployment.unit."myappl.war".PARSE:JBAS018733:无法执行 部署"myappl.war"的处理阶段PARSE由以下原因引起: java.lang.IllegalStateException:JBWS021001:意外元素 解析处理程序:handler-config

11:19:55,195 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.deployment.unit."myappl.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myappl.war".PARSE: JBAS018733: Failed to process phase PARSE of deployment "myappl.war" Caused by: java.lang.IllegalStateException: JBWS021001: Unexpected element parsing handlers: handler-config

推荐答案

此问题的根本原因是EAP 6.3.x基于Java EE 6规范,而JPA 2.0是该规范的一部分. Hibernate的最新版本(4.3.x)带有JPA 2.1版,它是Java EE 7规范的一部分.从理论上讲,要解决此问题,在jboss-deployment-structure.xml文件中排除"org.hibernate"模块和"javax.persistence"就足够了,但是并不能解决问题.根据Red Hat的说法,这是一个错误.

The root cause of this problem is that EAP 6.3.x is based on the Java EE 6 specification and JPA 2.0 is part of this specification. The most recent versions of Hibernate (4.3.x) bring with version 2.1 of JPA, which is part of the Java EE 7 specification. Theoretically, to solve the problem, it was enough to exclude 'org.hibernate' modules and 'javax.persistence' in jboss-deployment-structure.xml file, but it does not solve the problem. According to Red Hat, this is a BUG.

1)一种解决方案是使用EAP 6.3.x发行版中存在的Hibernate版本.解决,但不能将应用程序保留在服务器库的版本中.

1) A solution is to use the version of Hibernate present in the distribution of EAP 6.3.x. Resolve, but an application can not be held to versions of a server libraries.

2)另一个解决方案是直接在发行版中的JPA 2.0版本更改为2.1,该发行版位于\ JBOSS_DIST \ modules \ system \ layers \ base \ javax \ persistence \ api \ main.也可以解决,但是这种解决方案是不可接受的,因为使用EAP中存在的Hibernate版本6.3.x的应用程序可能会受到影响.

2) Another solution is to change the version of JPA 2.0 to 2.1 directly in the distribution, located in \JBOSS_DIST\modules\system\layers\base\javax\persistence\api\main. Also resolves, but this solution is not acceptable, since the applications using the Hibernate version 6.3.x present in the EAP may be affected.

3)我们可能会按照此地址中的步骤操作

3) We could would be to follow the steps in this address http://mariemjabloun.blogspot.com.br/2014/03/use-jboss-jpa-21-and-hibernate-43-on.html, but particularly found a solution very laborious.

4)最后,经过大量搜索和尝试,在RedHat的站点上找到了解决该问题的合理解决方案:

4) Finally, after numerous searches and attempts, found a reasonable solution to work around the problem, at the very site of RedHat: https://access.redhat.com/solutions/404223. I believe in future versions of EAP, it should be corrected.

这篇关于使用Jboss EAP 6.1在代码中使用javax.persistence.JoinColumn.foreignKey批注时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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