Home » Support » Forum » Dependency from enhanced classes to the objectDB library

Dependency from enhanced classes to the objectDB library

#1

Hello,
we have a Question to the dependency from enhanced classes (required for license) to the objectDB library.
Our Business Objects are the JPA entities. We developed  our product domain driven. This means we have several domains. Each domain is split into business layer and persistence layer (others are not relevant here). Per domain and per layer, we have an OSGI bundles. The business layer should have no dependency down. The persistence Layers have a dependency to the business layer and to the central DataAccess Layer. The Central DataAccess Layer has a dependency on JPA & ObjectDB and to all domains, because there are the entities.
Now we get an error when we have enhanced the entities.

java.lang.NoClassDefFoundError: com/objectdb/spi/TrackableUserType
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:272)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:632)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:588)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:540)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:527)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:324)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:320)
at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:36)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:391)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.btc.ep.requirement.dal.test.ut.IT_DALSaveAndLoadTest.test1(IT_DALSaveAndLoadTest.java:75)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
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.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
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.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: java.lang.ClassNotFoundException: com.objectdb.spi.TrackableUserType cannot be found by com.btc.ep.requirement.bl.impl_2.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 62 more

 

We have tried to include ObjectDB as OSGi component. But then the persistence unit is not found (defined in persistence.xml)
Do you have any idea how you can help us?

 

#2

Please see this forum thread regarding using ObjectDB with OSGi. If you add dependency of the business layer on ObjectDB then try setContextClassLoader, as suggested in post #4 in that thread before working with ObjectDB.

The test project in this forum thread may also help.

 

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

Hello, we don’t know how we must change the ContextClassLoader that is works. All our experiments have failed.


We have create a “small” example based on our OSGi Bundle structure.
The example contains 7 eclipse projects. (We use Eclipse Standard 4.4.1 (Luna) including: RCP development extension)

The project “com.btc.ep.base.dal.tests.it” contains a Plug-In Unit test. This test runs only if we allow the usage of not enhanced classes.

<entities>
<enhancement agent="false" reflection="warning" />

We have an ANT script in “com.btc.ep.base.dal.impl” to enhance the classes. The log of the enhancer is correct. But in the test we get the same error.

When we had the entities still in the com.btc.ep.base.dal.impl Bundle, it worked.

Can you tell us what we did wrong?

application/zip iconexample.zip (5.24MB)
Eclipse OSGi Example
#4

Please provide step by step instructions on how to use this example to get the exception on #1 (or if the example demonstrates a different exception, please describe it in details).

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

Hello,
in the example of post #3, we get a different error message than in post #1. I had not described in post #3 clear enough. The other message is because we have referenced the ObjectDB library in the bundle "com.btc.ep.base.bl.impl”. In the hope that it brings us closer to the solution.


Error message to the example in post #3 is:

[ObjectDB 2.5.7_07] javax.persistence.PersistenceException
Type com.btc.ep.base.bl.impl.ModelElementImpl is not enhanced (enhance the type or enable reflection) (error 304)
at com.objectdb.jpa.EMF.createEntityManager(EMF.java:260)
at com.btc.ep.dal.persist.impl.PersistenceManagerImpl.getPersistenceService(PersistenceManagerImpl.java:110)
at com.btc.ep.base.dal.tests.it.BaseTest.getPersistenceService(BaseTest.java:51)
at com.btc.ep.base.dal.tests.it.BaseTest.deleteDatabase(BaseTest.java:40)
at com.btc.ep.base.dal.tests.it.IT_DALSaveAndLoadTest.setUp(IT_DALSaveAndLoadTest.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: com.objectdb.o.UserException: Type com.btc.ep.base.bl.impl.ModelElementImpl is not enhanced (enhance the type or enable reflection)
at com.objectdb.o.MSG.d(MSG.java:62)
at com.objectdb.o.TYM.aJ(TYM.java:1377)
at com.objectdb.o.UTY.W(UTY.java:544)
at com.objectdb.o.UTY.S(UTY.java:389)
at com.objectdb.o.TYS.l(TYS.java:171)
at com.objectdb.o.TYM.ae(TYM.java:511)
at com.objectdb.o.TYM.<init>(TYM.java:194)
at com.objectdb.o.OMF.ao(OMF.java:811)
at com.objectdb.o.OMF.an(OMF.java:765)
at com.objectdb.jpa.EMF.an(EMF.java:238)
at com.objectdb.o.OMF.am(OMF.java:693)
at com.objectdb.jpa.EMF.createEntityManager(EMF.java:257)
... 49 more

 

Back to the problem of post #1

In the example (Eclipse OSGi Example #2) I have the ObjectDB removed from the bundle "com.btc.ep.base.bl.impl". Now we get the error message from post #1.

java.lang.NoClassDefFoundError: com/objectdb/spi/TrackableUserType
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:272)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:632)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:588)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:540)
at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:527)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:324)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:320)
at org.eclipse.osgi.internal.loader.sources.SingleSourcePackage.loadClass(SingleSourcePackage.java:36)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:391)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.osgi.internal.framework.ContextFinder.loadClass(ContextFinder.java:126)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.objectdb.o.ACL.loadClass(ACL.java:113)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.objectdb.o.TYM.ay(TYM.java:1014)
at com.objectdb.o.UTY.initSysType(UTY.java:331)
at com.objectdb.o.TYS.l(TYS.java:166)
at com.objectdb.o.TYM.ae(TYM.java:511)
at com.objectdb.o.TYM.<init>(TYM.java:194)
at com.objectdb.o.OMF.ao(OMF.java:811)
at com.objectdb.o.OMF.an(OMF.java:765)
at com.objectdb.jpa.EMF.an(EMF.java:238)
at com.objectdb.o.OMF.am(OMF.java:693)
at com.objectdb.jpa.EMF.createEntityManager(EMF.java:257)
at com.btc.ep.dal.persist.impl.PersistenceManagerImpl.getPersistenceService(PersistenceManagerImpl.java:110)
at com.btc.ep.base.dal.tests.it.BaseTest.getPersistenceService(BaseTest.java:51)
at com.btc.ep.base.dal.tests.it.BaseTest.deleteDatabase(BaseTest.java:40)
at com.btc.ep.base.dal.tests.it.IT_DALSaveAndLoadTest.setUp(IT_DALSaveAndLoadTest.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: java.lang.ClassNotFoundException: com.objectdb.spi.TrackableUserType cannot be found by com.btc.ep.base.bl.impl_2.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 78 more

 

How to use the example step-by-step:
1) Import all projects of the example #2 into your Eclipse (We use Eclipse Standard 4.4.1 (Luna) including: RCP development extension)
2) Run the project “com.btc.ep.base.dal.tests.it” as Junit Plug-in Test.
    -> You get the “Type com.btc.ep.base.bl.impl.ModelElementImpl is not enhanced” Exception.
3) Run the enhanced –map.xml, of project com.btc.ep.dal.impl, as Ant Build.
    -> This should enhance three classes.
4) The run the project “com.btc.ep.base.dal.tests.it” as Junit Plug-in Test again.
     -> You get the Exception of post #1


Can you start the test and you get the same error message? Or you still need more information on using?

Best regards, BTC

application/zip iconexample_2.zip (5.23MB)
Eclipse OSGi Example #2
#6

Following your instructions these exceptions are now generated.

On #1 above you wrote: "We have tried to include ObjectDB as OSGi component. But then the persistence unit is not found (defined in persistence.xml)".

Could you please adjust your example this way, i.e. include ObjectDB as OSGi component, and upload a revised example?

Then we may be able to solve the persistence unit not found exception using the hint at #2.

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

Hello support,

the example (Eclipse OSGi Example #3) is now adapted: The ObjectDB is now referenced as an OSGi bundle.
So that the example can use, ObjectDB lib (Version 2.5.7_07 from com.btc.ep.dal.impl/lib) must be added to the target platform.
The use of the example has not changed (see post #5).

The Stack Trace of the Persistence unit is not found exception:

[ObjectDB 2.5.7_07] javax.persistence.PersistenceException
Persistence unit 'eppdb' is not found (by org.eclipse.osgi.internal.framework.ContextFinder) (error 222)
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:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at com.btc.ep.dal.provider.impl.OdbPersistenceManagerProvider.getEntityManagerFactory(OdbPersistenceManagerProvider.java:59)
at com.btc.ep.dal.persist.impl.PersistenceManagerImpl.getPersistenceService(PersistenceManagerImpl.java:109)
at com.btc.ep.base.dal.tests.it.BaseTest.getPersistenceService(BaseTest.java:51)
at com.btc.ep.base.dal.tests.it.BaseTest.deleteDatabase(BaseTest.java:40)
at com.btc.ep.base.dal.tests.it.IT_DALSaveAndLoadTest.setUp(IT_DALSaveAndLoadTest.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Caused by: com.objectdb.o.UserException: Persistence unit 'eppdb' is not found (by org.eclipse.osgi.internal.framework.ContextFinder)
at com.objectdb.o.MSG.d(MSG.java:62)
at com.objectdb.o.UNM.w(UNM.java:77)
at com.objectdb.jpa.Provider.createEntityManagerFactory(Provider.java:58)
... 53 more

Best regards, BTC

application/zip iconexample_3.zip (2.68MB)
Eclipse OSGi Example #3
#8

> So that the example can use, ObjectDB lib (Version 2.5.7_07 from com.btc.ep.dal.impl/lib) must be added to the target platform.

Please explain exactly in which projects and where this should be done.

Three projects are currently with compilation errors (JPA types are missing).

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

The target-platform does not refer to a single project, but refers to the current workspace.
To add objectDB lib to the target platform proceed as follows:
1) Window -> Preferences
2) In the Preferences editor: Unfold “Plug-in Development” and select the entry “Target Platform”
3) In the Target Platform view: Selcet the active target definition and push the button “edit”
   -> The “Edit Target Definition” Editor opens.
4) Use “Add” to add a new Location:
    a. At first step (select Content) select “Directory” and push next.
    b. Browse to the folder [example]\EPDataManagement\com.btc.ep.dal.impl\main\lib and push next.
    c. The Preview Contents view must list one Plug-ins: com.objectdb (2.5.7.b07)
    d. Push Finish -> the add dialog closes.
    e. Open the tab Content and make sure that the ObjectDB is selected.
    f. Push Finish in the “Edit Target Definiton” Editor. The Editor closes.
    g. Push “Apply” and then Ok.
Now the JPA types are found.

#10

Finally we succeeded to pass your test case with enhanced classes.

We used a new version of ObjectDB, 2.6.0, in which the objectdb.jar (when used as an OSGi bundle) exports types that enhanced classes reference. Still OSGi support is far from perfect, so there are limitations.

To run the test case:

  1. Download and extract the attached example_4.zip file.
  2. Import ObjectDB as a bundle to Eclipse:
    File > Import > Plug-in Development > Plug-ins and Fragments > Next
    Specify the location of objectdb.jar file (example_4\EPDataManagement\com.btc.ep.dal.impl\main\lib) > Next
    Select com.objectdb (2.6.0) > Existing Plug-ins > Finish
  3. Import your 7 projects.
  4. Run the enhanced –map.xml of project com.btc.ep.dal.impl, as Ant Build.
  5. Run the project “com.btc.ep.base.dal.tests.it” as Junit Plug-in Test.

In addition to switching to a new ObjectDB version the following changes have been applied to your project:

  1. Dependency on com.objectdb (2.6.0) has been added to some of your projects.
  2. Annotations have been added to your entity classes (since ObjectDB cannot find the mapping file).
  3. The type of the path field in ProfileImpl has been changed to String (since the configuration file that enables serialization is not found).
  4. In OdbPersistenceManagerProvider, persistence unit has been changed to "eppdb.odb" (since the persistence.xml file is not found).
  5. In PersistenceManagerImpl.getPersistenceService(), setContextClassLoader was added.

Possibly there are better solutions for changes 2-4 above.

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

Hello Support,
these are some limitations.
Regarding item:
  1) The Dependency on com.objectdb (2.6.0) to our projects (*.bl and *.bl.impl) is not nice. This projects(bundles) contains our BussinessLogic and we hope we can test this bundles without dependencies to the ObjectDB.
  2) How could look a solution? The switch to annotations would be associated with some effort for us.
  3) What would a solution to find the configuration file? The serialization is a required feature.
  4) I think this would be required to use a Mapping file.
  5) This solution work only with one domain. But we have many domains.

 

Example # 4 works. But the example contains only one domain.

With multiple domains, it no longer works.


We have added two domains to the example #4. (see Example #5)
To run the test cases in Example 5:
    Download and extract the attached example_5.zip file.
    Import ObjectDB as a bundle to Eclipse.
    Import the 15 projects.
    Run the project “com.btc.ep.base.dal.tests.it” as Junit Plug-in Test. -> OK
    Run the project “com.btc.ep.domainTwo.dal.tests.it” as Junit Plug-in Test. -> OK
    Run the project “com.btc.ep.domainThree.dal.tests.it” as Junit Plug-in Test. -> Failed!


See our comment in PersistenceManagerImpl.getPersistenceService () setContextClassLoader. We have not found working configuration with which the tests "domainTwo" and "domainThree" run.


Furthermore, the modification of the class loader is very ugly, because then the class loader of the UI is modified. And when or where the changes would make undone?

application/zip iconexample_5.zip (2.74MB)
Eclipse OSGi Example #5
#12

Your test case and questions demonstrate the current limitations of using ObjectDB with OSGi. Hopefully most of these limitations will be removed in future ObjectDB versions.

Following are some explanations and suggestions for workarounds:

  1. Enhanced classes depend on internal ObjectDB classes. Therefore, enhanced classes cannot be loaded if ObjectDB is not available in the classpath, and dependency on ObjectDB bundle is required for every bundle that includes enhanced classes. Before enhancement you can use a bundle of entity classes without dependency on ObjectDB, but such dependency has to be added once classes are enhanced.
  2. You can use a mapping file instead of annotations, but you will have to move the META-INF/orm.xml file to the project that contains the entity classes, so it will be found using the thread context class loader (which is also used to load the classes).
  3. To use your ObjectDB configuration replace the META-INF/objectdb.conf file that is embedded in objectdb.jar with your objectdb.conf file.
  4. Similarly to 3, you may embed META-INF/persistence.xml in objectdb.jar and access ObjectDB using a standard persistence unit.
  5. Eventually all the issues with OSGi are with class (and resource) loading. If your entity classes are in several different projects you will still need one class loader that can load all the entity classes in order to set it as the thread context class loader for ObjectDB. You can define your own custom class loader, or use a system class loader that can load all the entity classes. You may have to export entity classes from bundles to make them visible.

It should not be too difficult to improve OSGi support in ObjectDB. We may have to define an alternative way to pass relevant class loaders to ObjectDB, instead of using the context class loader, and maybe support several class loaders, including for loading XML files. If you are interested, please create a feature request and try to define from your point of view how exactly it should work.

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

Hello support,
thanks for the comments. We will probably make a feature request but we need some time to define from our point of view how exactly it should work.

In the meantime, we have experimented a bit:
We have ObjectDB imported as a bundle in Eclipse.
A fragment created for this new ObjectDB bundle that contains the xml files (persitence.xml & orm.xml) and has a reference to all bundles with entities.

Basically this works.
But only as long as we do not exceed the ratings limit or deactivate (error) reflection in the configuration for enhancement.

[ObjectDB 2.5.7_07] javax.persistence.PersistenceException
Type com.btc.ep.base.bl.impl.ModelElementImpl is not enhanced (enhance the type or enable reflection) (error 304)

This effect, we can not understand. It is the effect which we have already described in post #3.
Since we did not have to modify the context class loader in this scenario, we hope that this approach could be a solution. Can you look at that again?

#14

Try moving the orm.xml file to the bundle of the entity classes.

In addition, the error message indicates using ObjectDB 2.5.7_07. You should use 2.6.0 or above.

Using a fragment is a good idea. If you can upload Example #6 with these changes it may help.

 

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

Hello,

we have move the orm.xml in every bundle that contains entities.

Every bundle with entities will be enhanced in an owned ant task.

But the enhancer has following error output, when we start our test.

[ObjectDB 2.6.0_02] javax.persistence.PersistenceException
Type com.btc.ep.requirement.bl.impl.RequirementsSourceImpl is not enhanced (enhance the type or enable reflection) (error 304)
at com.objectdb.jpa.EMImpl.persist(EMImpl.java:445)
 

If all entity bundles will be enhanced in single ant task, then the test works fine.

But we need a particular enhancement for every bundle.

Best regards, BTC-ES

#16

The cause of this error is unclear.

We have tried enhancing in two steps with the following test case, but it works well:

import javax.persistence.*;


public final class T1574
{
    public static void main(String[] args) {
   
        com.objectdb.Enhancer.enhance(E1.class.getName());
        com.objectdb.Enhancer.enhance(E2.class.getName());

        EntityManagerFactory emf =
            Persistence.createEntityManagerFactory(
                "objectdb:$objectdb/db/test.tmp;drop");
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        em.persist(new E1());
        em.persist(new E2());
        em.getTransaction().commit();
        emf.close();
    }
   
    @Entity static class E1 {}
    @Entity static class E2 extends E1 {}
}

A test case that demonstrates the issue is needed in order to explore it.

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

I want to upload a test case. The test case zip archive has a size of 1.35 MB.

But the upload causes following errors:

An unrecoverable error occurred. This form was missing from the server cache. Try reloading the page and submitting again.

 

And a reload of the page or restart of the browser have the same result. I tried it with IE and firefox.

Can you check your upload?

 

 

#18

Please try uploading the file again, it should work now.

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

The test case has three ant task files. You must insert your own activation code in the objectdb.conf.

Clean up the project and execute the enhancerall.xml. All entities will be enhanced. After that the unit test works well.

Clean up the project and execute enhancerbase.xml and enhancerrequirement.xml. After that the unit test has following error:

[ObjectDB 2.6.0_02] javax.persistence.PersistenceException
Type com.btc.ep.requirement.bl.impl.RequirementsSourceImpl is not enhanced (enhance the type or enable reflection) (error 304)

We need several ant tasks in our project, because we develop many independently modules those contained entities.

application/zip iconcom.btc_.entities.zip (1.35MB)
Test Case Enhancement
#20

The error message is misleading since all the classes are indeed enhanced. However, ObjectDB cannot use the enhancement of RequirementsSourceImpl (and forced to use reflection), because at runtime it finds out that RequirementsSourceImpl has a different persistent structure then the persistent structure that was recorded at enhancement.

In this test, RequirementsSourceImpl is enhanced as top level entity class, since it super class is not declared as an entity class for enhancement, and at runtime it is not a top level entity class but a subclass of another entity class.

This error can be fixed easily in the definition of the "requirement" persistence unit in the persistence.xml file:

    <description>EPP</description>
        <provider>com.objectdb.jpa.Provider</provider>
        <mapping-file>META-INF/ormrequirement.xml</mapping-file>
        <mapping-file>META-INF/ormbase.xml</mapping-file>

Adding the second orm file will let the Enhancer know that the base classes are also entity classes.

This forum thread already discusses several different topics. Please use a separate thread for each subject, so other users will be able to locate relevant questions and answers easily.

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

Hello Support,
yes in this thread Several topics were discussed.
The basic Topic was a dependency and Class loading problem of enhanced classes in OSGi environment.
The last post to this Topic is post #14.

The posts after #14 refer to problems with the enhancer.


We have now found that our solution from post #13 works.
The problem was a bug in the enhancer script. (The classes was enhanced as NON persistable types)

-> This solution with the fragment (see post#13) we are now using.

Speaks from your point of view something about this solution?

#22

Currently your solution at #13 looks a the best option under the current constraints.

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

Post Reply

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