Hibernate:找不到提供者com.bea.xml.stream.EventFactory

时间:2017-06-27 06:12:04

标签: hibernate osgi

我正在让Hibernate与OSGi一起工作,所以这个项目的基础是org.hibernate.osgi

我已经创建了 persistence.xml ,并尝试使用以下代码访问它:

BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
ServiceReference serviceReference = context.getServiceReference(PersistenceProvider.class.getName());
PersistenceProvider persistenceProvider = (PersistenceProvider) context.getService(serviceReference);
EntityManagerFactory emf = persistenceProvider.createEntityManagerFactory("DemoUnit", null);

出于某种原因,在创建EntityManagerFactory时,会出现以下异常:

javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.EventFactory not found
at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)
at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:178)
at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)
at javax.xml.stream.XMLEventFactory.newInstance(XMLEventFactory.java:30)
at org.hibernate.boot.jaxb.internal.MappingBinder.<init>(MappingBinder.java:40)
at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43)
at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:208)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:177)
at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:83)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:186)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:126)
at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:81)
at org.hibernate.osgi.OsgiPersistenceProvider.createEntityManagerFactory(OsgiPersistenceProvider.java:77)
at org.acme.project.MyTest.getFactory(MyTest.java:28)

我认为这是一个错误,因为我在任何P2存储库和Maven中心都找不到包com.bea.xml.stream

但是如何让Hibernate接受任何其他XML提供程序?

(或者com.bea.xml.stream可能是什么。至少代码试图将这个'EventFactory'强制转换为'XMLEventFactory'。)

1 个答案:

答案 0 :(得分:1)

没有人能找到任何东西。打破Hibernate的包是com.springsource.javax.xml.stream。我用javax.xml.stream替换它,现在它可以工作。