ObjectDB without javax.persistence

#1

Hello,
what we need to do, that we can use a separate bundle for javax.persistence in a OSGi envoirement.

We tried to use the objectdb-jee.jar instead of objectdb.jar. And a separate bundle for javax.persistence that only contains the Java Persistence API.
So that the ObjectDB PersistenceProvider get visible for the JavaPersistenceAPI, we have registered the ObjectDB as Buddy.


But now we get a “com.objectdb.o._PersistenceException:” with the message “Failed to validate xml file bundleresource://134.fwk2011579990:2/META-INF/persistence.xml”

 

Caused by: com.objectdb.o._PersistenceException: Failed to validate xml file bundleresource://134.fwk2011579990:2/META-INF/persistence.xml:
at com.objectdb.o._PersistenceException.b(_PersistenceException.java:45)
at com.objectdb.jpa.Provider.createEntityManagerFactory(Provider.java:88)
at com.objectdb.jpa.Provider.createEntityManagerFactory(Provider.java:32)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at com.btc.ep.dal.provider.impl.OdbPersistenceManagerProvider.getEntityManagerFactory(OdbPersistenceManagerProvider.java:129)
at com.btc.ep.base.transactions.internal.TransactionManagerImpl.getEntityManagerFactory(TransactionManagerImpl.java:84)
at com.btc.ep.base.transactions.internal.TransactionManagerImpl.doInit(TransactionManagerImpl.java:146)
at com.btc.ep.base.transactions.internal.TransactionManagerImpl.init(TransactionManagerImpl.java:133)
at com.btc.ep.base.transactions.annotations.TransactionAspect.ajc$around$com_btc_ep_base_transactions_annotations_TransactionAspect$1$adc4043c(TransactionAspect.aj:94)
at com.btc.ep.base.al.internal.ProfileApplicationServiceImpl.createNewProfile(ProfileApplicationServiceImpl.java:131)
at com.btc.ep.base.ui.session.SessionManager.createNewSession(SessionManager.java:205)
at com.btc.ep.base.ui.navigator.ProfileNavigator.refresh(ProfileNavigator.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
... 23 more
Caused by: com.objectdb.o.UserException: Failed to validate xml file bundleresource://134.fwk2011579990:2/META-INF/persistence.xml:
at com.objectdb.o.MSG.d(MSG.java:75)
at com.objectdb.o.XMD.n(XMD.java:224)
at com.objectdb.o.XMD.k(XMD.java:155)
at com.objectdb.o.UNM$z._e(UNM.java:182)
at com.objectdb.o.UNM$z.<init>(UNM.java:169)
at com.objectdb.o.UNM.x(UNM.java:105)
at com.objectdb.o.UNM.w(UNM.java:75)
at com.objectdb.jpa.Provider.createEntityManagerFactory(Provider.java:58)
... 39 more
Caused by: java.lang.NullPointerException
at javax.xml.validation.SchemaFactory.newSchema(SchemaFactory.java:659)
at com.objectdb.o.XMD.n(XMD.java:206)
... 45 more

We get this exception even if we try to create the EntityManager as:

String DB_FILE = "eppdb.odb";
this.entityManagerFactory = Persistence.createEntityManagerFactory("$objectdb/" + DB_FILE);

The persistence.xml which we have used:

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
  version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">

  <persistence-unit name="eppdb" transaction-type="RESOURCE_LOCAL">
   <description>EPP</description>
   <provider>com.objectdb.jpa.Provider</provider>
   <properties>
      <property name="javax.persistence.jdbc.url" value="$objectdb/eppdb.odb"/>
      <property name="javax.persistence.jdbc.user" value="admin"/>
      <property name="javax.persistence.jdbc.password" value="admin"/>
    </properties>
  </persistence-unit>
</persistence>

Have you any idea or an example with a separate JPA Bundle?

(In the In the Java EE tutorial, you use the ObjectDB with the JavaPersistence API as in the JavaSE Tuturial.)

#2

With a javax.persistence bundle without direct OSGi support (org\eclipse\persistence\javax\persistence\osgi) and in addition javax.transaction for ObjectDB it works, if we don't use the persistence.xml file.

#3

The objectdb-jee.jar is for using ObjectDB with some Java EE application servers, where using objectdb.jar causes a class loading conflict. However, separating JPA from ObjectDB for OSGi environment has never been tested, and objectdb-jee.jar has not been created for this purpose.

This specific reported exception indicates a failure to locate an xsd file for validating persistence.xml.

objectdb.jar includes the following xsd files:

  •     javax/persistence/persistence_2_1.xsd
  •     javax/persistence/persistence_2_0.xsd
  •     javax/persistence/persistence_1_0.xsd
  •     javax/persistence/orm_2_1.xsd
  •     javax/persistence/orm_2_0.xsd
  •     javax/persistence/orm_1_0.xsd

Please check, and if adding them to objectdb-jee.jar solves the problem we can fix it in future releases.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login