我得到的错误是这样的:
`javax.xml.stream.FactoryConfigurationError:无法在 javax.xml.stream.FactoryFinder.find 的 javax.xml.stream.FactoryFinder.findServiceProvider(FactoryFinder.java:370) 中创建类 javax.xml.stream.XMLInputFactory 的提供程序( FactoryFinder.java:313) 在 javax.xml.stream.FactoryFinder.find(FactoryFinder.java:227) 在 javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:154) 在 org.hibernate.service.internal.JaxbProcessor .buildStaxFactory(JaxbProcessor.java:107) 在 org.hibernate.service.internal.JaxbProcessor.staxFactory(JaxbProcessor.java:100) 在 org.hibernate.service.internal.JaxbProcessor.unmarshal(JaxbProcessor.java:79) 在 org. hibernate.service.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:69) 在 org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl。mergePropertySources(EntityManagerFactoryBuilderImpl.java:549) 在 org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.(EntityManagerFactoryBuilderImpl.java:214) 在 org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:51) 在org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:182) at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:131) at org.hibernate.ejb.HibernatePersistence.getEntityManagerFactoryBuilderOrNull(HibernatePersistence.java:93)在 org.hibernate.ejb.HibernatePersistence 的 org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:88)。getEntityManagerFactoryBuilderOrNull(HibernatePersistence.java:101) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:69) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54) at javax.persistence.Persistence.createEntityManagerFactory (Persistence.java:48) 在 javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32) 在 org.capgemini.test.RoutingPointTest3.setUpBeforeClass(RoutingPointTest3.java:33) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method ) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:498) 在 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) 在 org.junit.runners 的 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)。 model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) at org.junit.runners.ParentRunner.run(ParentRunner.java:363)在 org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) 在 org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 在 org.eclipse .jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) 在 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) 在 org.eclipse.jdt.internal .junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) 原因:java.lang.RuntimeException:类 javax 的提供程序.xml.stream.XMLInputFactory 无法在 javax.xml.stream.FactoryFinder.findServiceProvider(FactoryFinder.java:367) ... 35 处创建更多原因:java.util.ServiceConfigurationError: javax.xml.stream.XMLInputFactory: Provider com在 java.util.ServiceLoader.access$300(ServiceLoader.java:185) 在 java.util.ServiceLoader$LazyIterator 的 java.util.ServiceLoader.fail(ServiceLoader.java:239) 中找不到 .ctc.wstx.stax.WstxInputFactory。 nextService(ServiceLoader.java:372) at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404) at java.util.ServiceLoader$1.next(ServiceLoader.java:480) 在 javax.xml.stream.FactoryFinder.findServiceProvider(FactoryFinder.java:341) 的 java.security.AccessController.doPrivileged(Native Method) 的 javax.xml.stream.FactoryFinder$1.run(FactoryFinder.java:353)。 .. 还有 35 个
`
我试图对我的类路由点进行测试,代码如下:
public class RoutingPointTest3 {
private static EntityManager em;
private static
EntityManagerFactory emf;
private static final String PERSISTENCE_UNIT_NAME = "sample";
@BeforeClass
public static void setUpBeforeClass() throws Exception {
emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
em = emf.createEntityManager();
}
@Test
public void test() {
EntityTransaction tx = em.getTransaction();
tx.begin();
RoutingPoint rp = new RoutingPoint();
rp.setRoutingPoint(0753);
em.persist(rp);
tx.commit();
long id = rp.getId();
assertNotNull("Id not null", id);
em.close();
RoutingPoint rp2 = em.find(RoutingPoint.class, id);
assertNotNull("routing point from database", rp2);
}
}