本文介绍了与openejb容器和休眠集成测试失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在为我的java ee 6应用程序编写集成测试。 这适用于打开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验证-P hibernate -b 这是我得到的错误: 测试运行:1,失败:0,错误:1,跳过:0,经过的时间:1.816秒 be.crydust.guestbooktwo.ejb.PostBoundaryIT经过的时间:1.816秒 $ org.apache.openejb.OpenEjbContainer AssembleApplicationException:org.apache.openejb.OpenEJBException:创建应用程序失败:d:\home\kristof\Projects\guestbooktwo\target:使用javax /持久/转换器$在java.net.URLClassLoader $ 1.run(URLClassLoader.java:366)在java.net.URLClassLoader $ 1.run(URLClassLoader.java:355)$ b $在java.security.AccessController。在java.net.URLClassLoader.findClass(URLClassLoader.java:354)处使用。在java.lang.ClassLoader.loadClass处使用(ClassLoader.java:425)$ 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)在org.hibernate.jpa.boot.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:74)。在org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.processDirectory(ExplodedArchiveDescriptor.java:167)在org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.processDirectory(ExplodedArchiveDescriptor.java:142)。在org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.processDirectory(ExplodedArchiveDescriptor.java:142)在org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.processDirectory(ExplodedArchiveDescriptor.java :142)。在org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.processDirectory(ExplodedArchiveDescriptor.java:142)。在org.hibernate.jpa.boot.archive.internal.ExplodedArchiveDescriptor.visitArchive (ExplodedArchiveDescriptor.java:78)在org.hibernate.jpa.boot.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:72)在org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl .scan(EntityManagerFactoryBuilderImpl.java:723)a吨org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl< INIT>(EntityManagerFactoryBuilderImpl.java:219)。在org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl< INIT>(EntityManagerFactoryBuilderImpl.java。: at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:45) at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java: 57)美元,org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:150 b $ b)在org.apache.openejb.assembler.classic.EntityManagerFactoryCallable.call(EntityManagerFactoryCallable.java:55)$ b在org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory.createDelegate(ReloadableEntityManagerFactory.java:115) $ b。在org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory<初始化>(ReloadableEntityManagerFactory.java:101 )在org.apache.op上 enejb.assembler.classic.PersistenceBuilder.createEntityManagerFactory(PersistenceBuilder.java:150)处org.apache org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:752)。 openejb.assembler.classic.Assembler.createApplication(Assembler.java:612)维持在javax.ejb.embeddable org.apache.openejb.OpenEjbContainer $ Provider.createEJBContainer(OpenEjbContainer.java:415) 。 EJBContainer.createEJBContainer(EJBContainer.java:56) be.crydust.guestbooktwo.ejb.PostBoundaryIT.startTheContainer(PostBoundaryIT.java:31) 我真的认为profile hibernate-b可以工作。 有人知道我在做什么错吗? 看起来像这可能是相关的: 解决方案我修复了它。该项目现在与openjpa,eclipselink,hibernate 4.2.x和hibernate 4.3.x一起工作。 openejb和tomee的稳定版本不支持hibernate 4.3.x.因此快照版本是必需的。 此处更新代码: https://github.com/Crydust/guestbooktwo 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/guestbooktwoThese workD:\Projects\guestbooktwo>mvn clean verify -P openjpaD:\Projects\guestbooktwo>mvn clean verify -P eclipselinkThese don't workD:\Projects\guestbooktwo>mvn clean verify -P hibernate-aD:\Projects\guestbooktwo>mvn clean verify -P hibernate-bThis 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.PostBoundaryITbe.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 解决方案 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 这篇关于与openejb容器和休眠集成测试失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-04 18:54