Parent last for Hibernate Arquillian test on JBOSS

匿名 (未验证) 提交于 2019-12-03 01:41:02

问题:

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

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.

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:

  1. Added a META-INF/jboss-classloading.xml (to the JAR and the EAR)

  2. Added a META-INF/jboss-deployment-structure.xml (to the JAR and the EAR) in attempt to exclude the parent Hibernate:

  3. Delete the Hibernate JARs from JBOSS - that broke the server altogether

Following are a few configuration aspects of my setup:

  • 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
  • Pointing to an unpacked jboss-as-7.1.1.Final
  • 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>

Anything else? :)

Your help much appreciated!

回答1:

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.

Or better use the Hibernate 4 JPA provider supplied by the container unless you have a reason to use Hibernate 3.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!