上一次在JBOSS上进行Hibernate Arquillian测试的父级 [英] Parent last for Hibernate Arquillian test on JBOSS
问题描述
我正在接受Arquillian测试.主题是使用Hibernate 3的EJB,我将其与所有其他Maven依赖项一起添加到了收缩包装的档案中.它将EJB作为包裹在EAR中的JAR部署到板上的具有Hibernate 4的嵌入式JBOSS 7.它与以下异常发生冲突:
I'm having an Arquillian test. The subject is an EJB that uses Hibernate 3, which I add to the shrinkwrapped archives along with all other Maven dependencies. It deploys the EJB as a JAR wrapped in an EAR, to an embedded JBOSS 7 which has Hibernate 4 on board. It clashes with the following exception:
java.lang.AbstractMethodError: org/hibernate/usertype/UserType.nullSafeSet(
Ljava/sql/PreparedStatement;Ljava/lang/Object;
ILorg/hibernate/engine/spi/SessionImplementor;)V
我坚信我的代码(针对Hibernate 3编译)针对Hibernate 4执行,因此出现错误.我的理解是,默认情况下,JBOSS会先执行父操作,这将解释该错误.我将存档内容打印出来,作为收缩包装的一部分,所以我相信Hibernate 3位于EAR中.
I strongly believe that my code (compiled against Hibernate 3) is executed against Hibernate 4, hence the error. JBOSS does parent first by default is my understanding, that would explain the error. I print out the archive contents as part of shrinkwrapping, so I believe I know Hibernate 3 is in the EAR.
我尝试过将JBOSS更改为最后一个父级,但是没有成功.其中一些可能是愚蠢的,但无论如何我还是尝试过:
I've tried changing JBOSS to parent last, but had no success at that. Some of these may be stupid, but I tried them anyway:
-
添加了
META-INF/jboss-classloading.xml
(到JAR 和 EAR)
Added a
META-INF/jboss-classloading.xml
(to the JAR and the EAR)
在META-INF/jboss-deployment-structure.xml
,试图排除父Hibernate:
Added a META-INF/jboss-deployment-structure.xml
(to the JAR and the EAR) in attempt to exclude the parent Hibernate:
从JBOSS删除Hibernate JAR,这完全破坏了服务器
Delete the Hibernate JARs from JBOSS - that broke the server altogether
以下是我的设置的一些配置方面:
Following are a few configuration aspects of my setup:
- 依赖项:
-
org.hibernate:hibernate-annotations:jar:3.4.0.GA:provided
-
org.hibernate:hibernate-core:jar:3.3.2.GA:provided
-
org.jboss.arquillian.junit:arquillian-junit-container:jar:1.1.1.Final:test
-
org.jboss.arquillian.protocol:arquillian-protocol-servlet:jar:1.1.1.Final:test
-
org.jboss.as:jboss-as-arquillian-container-managed:jar:7.1.1.Final:provided
-
org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven:jar:2.0.0:test
-
org.jboss.spec:jboss-javaee-web-6.0:pom:3.0.0.Final:provided
- Dependencies:
org.hibernate:hibernate-annotations:jar:3.4.0.GA:provided
org.hibernate:hibernate-core:jar:3.3.2.GA:provided
org.jboss.arquillian.junit:arquillian-junit-container:jar:1.1.1.Final:test
org.jboss.arquillian.protocol:arquillian-protocol-servlet:jar:1.1.1.Final:test
org.jboss.as:jboss-as-arquillian-container-managed:jar:7.1.1.Final:provided
org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-impl-maven:jar:2.0.0:test
org.jboss.spec:jboss-javaee-web-6.0:pom:3.0.0.Final:provided
META-INF/arquillian.xml
:<arquillian ...> <defaultProtocol type="Servlet 3.0" /> <container qualifier="jbossas-managed" default="true"> <configuration> ... </configuration> </container> </arquillian>
-
META-INF/application.xml
:<application ... version="5"> <module><ejb>test.jar</ejb></module> </application>
还有其他吗? :)
非常感谢您的帮助!
推荐答案
Since you're packaging Hibernate 3 in your application, you should specify the JPA provider as
hibernate3-bundled
in your persistence.xml file. Note that your current Hibernate 3.x version might not work and you may need to upgrade it to >= 3.5.或者最好使用容器提供的Hibernate 4 JPA提供程序,除非您有理由使用Hibernate 3.
Or better use the Hibernate 4 JPA provider supplied by the container unless you have a reason to use Hibernate 3.
这篇关于上一次在JBOSS上进行Hibernate Arquillian测试的父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
-