问题
I'm trying to write integration tests for my java ee 6 application. This works with open jpa and also with eclipselink. But is doesn't work with hibernate.
I've created a minimal project on github to debug the problem here: https://github.com/Crydust/guestbooktwo
These work
D:\Projects\guestbooktwo>mvn clean verify -P openjpa
D:\Projects\guestbooktwo>mvn clean verify -P eclipselink
These don't work
D:\Projects\guestbooktwo>mvn clean verify -P hibernate-a
D:\Projects\guestbooktwo>mvn clean verify -P hibernate-b
This is the error I get:
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)
I really thought profile hibernate-b would work. Does anyone know what I'm doing wrong?
Seems like this may be related:
http://comments.gmane.org/gmane.comp.java.openejb.user/15793
回答1:
I've fixed it. The project now works with openjpa, eclipselink, hibernate 4.2.x and hibernate 4.3.x. The stable versions of openejb and tomee don't work with hibernate 4.3.x. Therefore the snapshot version is required.
Updated code here:
https://github.com/Crydust/guestbooktwo
来源:https://stackoverflow.com/questions/21168943/integration-test-with-openejb-container-and-hibernate-fails