与openejb容器和hibernate的集成测试失败

时间:2014-01-16 17:38:36

标签: java hibernate java-ee jpa openejb

我正在尝试为我的java ee 6应用程序编写集成测试。 这适用于open jpa和eclipselink。 但是它不适用于hibernate。

我在github上创建了一个最小的项目来调试这里的问题: https://github.com/Crydust/guestbooktwo

这些工作

D:\Projects\guestbooktwo>mvn clean verify -P openjpa
D:\Projects\guestbooktwo>mvn clean verify -P eclipselink

这些不起作用

D:\Projects\guestbooktwo>mvn clean verify -P hibernate-a
D:\Projects\guestbooktwo>mvn clean verify -P hibernate-b

这是我得到的错误:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.816 sec <<< FAILURE! - in be.crydust.guestbooktwo.ejb.PostBoundaryIT
be.crydust.guestbooktwo.ejb.PostBoundaryIT  Time elapsed: 1.816 sec  <<< ERROR!
org.apache.openejb.OpenEjbContainer$AssembleApplicationException: org.apache.openejb.OpenEJBException: Creating application failed: D:\home\kristof\Projects\guestbooktwo\target: javax/persistence/Converter
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at org.hibernate.jpa.boot.scan.spi.ClassFileArchiveEntryHandler.containsClassAnnotationsOfInterest(ClassFileArchiveEntryHandler.java:112)
    at org.hibernate.jpa.boot.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:74)
    at org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.processDirectory(ExplodedArchiveDescriptor.java:167)
    at org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.processDirectory(ExplodedArchiveDescriptor.java:142)
    at org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.processDirectory(ExplodedArchiveDescriptor.java:142)
    at org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.processDirectory(ExplodedArchiveDescriptor.java:142)
    at org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.processDirectory(ExplodedArchiveDescriptor.java:142)
    at org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.visitArchive(ExplodedArchiveDescriptor.java:78)
    at org.hibernate.jpa.boot.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:72)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.scan(EntityManagerFactoryBuilderImpl.java:723)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:219)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:186)
    at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:45)
    at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:57)
    at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:150)
    at org.apache.openejb.assembler.classic.EntityManagerFactoryCallable.call(EntityManagerFactoryCallable.java:55)
    at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createDelegate(ReloadableEntityManagerFactory.java:115)
    at org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.<init>(ReloadableEntityManagerFactory.java:101)
    at org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:150)
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:752)
    at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:612)
    at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:415)
    at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
    at be.crydust.guestbooktwo.ejb.PostBoundaryIT.startTheContainer(PostBoundaryIT.java:31)

我真的认为配置文件hibernate-b会起作用。 有谁知道我做错了什么?

似乎这可能是相关的:
http://comments.gmane.org/gmane.comp.java.openejb.user/15793

1 个答案:

答案 0 :(得分:1)

我已经修好了。该项目现在适用于openjpa,eclipselink,hibernate 4.2.x和hibernate 4.3.x. opennejb和tomee的稳定版本不适用于hibernate 4.3.x.因此需要快照版本。

此处更新了代码:
https://github.com/Crydust/guestbooktwo