title: Hibernate: Provider com.bea.xml.stream.EventFactory not found
body: <p>I'm in the process of getting Hibernate to work with OSGi, so the base for this project is <code>org.hibernate.osgi</code>.</p>
  
  <p>I've created a <em>persistence.xml</em> and tried to access it with the following code:</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>For some reason, when creating the <code>EntityManagerFactory</code>, there is the following exception:</p>
  
  <pre><code>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.&lt;init&gt;(MappingBinder.java:40)
  at org.hibernate.boot.spi.XmlMappingBinderAccess.&lt;init&gt;(XmlMappingBinderAccess.java:43)
  at org.hibernate.boot.MetadataSources.&lt;init&gt;(MetadataSources.java:87)
  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.&lt;init&gt;(EntityManagerFactoryBuilderImpl.java:208)
  at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.&lt;init&gt;(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)
  </code></pre>
  
  <p>I assume this to be a bug, since I can't find the package <code>com.bea.xml.stream</code> in any P2 repository nor Maven central.</p>
  
  <p>But how do I get Hibernate to take any other XML provider? </p>
  
  <p>(Or whatever <code>com.bea.xml.stream</code> might be. At least the code is trying to cast this 'EventFactory ' to 'XMLEventFactory'.)</p>