ObectDb 2.3.6 in OSGi environment

#1

Hello,

I'm trying to use ObjectDb within OSGi bundles. I have one bundle for db accens which uses ObjectDb and another bundle which includes the POJO models. Everytime I start in plugin evironement i get an PersistenceException, because my POJO not found. If try the same test in normal Java environment everthing works fine. Can you please advice?

Thx

Peter

#2

Please provide more details, including the full stack trace of the exception.

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

I've two bundles, from the first bundle I'm trying to call the second bundle in following way with a JUnit Plugin test:

TypedQuery<RuleValueNode> query =  (TypedQuery<RuleValueNode>) this.dbService.createNamedQuery("RuleValueNode.findRoot", RuleValueNode.class);

the corresponding POJO:

@Entity
@NamedQueries({
  @NamedQuery(name = "RuleValueNode.findRoot", query = "SELECT rvn FROM RuleValueNode rvn where rvn.parent is null"),
  @NamedQuery(name = "RuleValueNode.findNotNodes", query = "SELECT rvn FROM RuleValueNode rvn where rvn.value.not = true and rvn.parent = :parent"),
  @NamedQuery(name = "RuleValueNode.findStandardNodes", query = "SELECT rvn FROM RuleValueNode rvn where rvn.value.not = false and rvn.parent = :parent") })
public class RuleValueNode implements IRuleValueNode, Cloneable {

In the dbService I've included com.objectDb as required bundle, and the simple access to the db:

@Override
public <T> TypedQuery<T> createNamedQuery(String name, Class<T> objClass) {
  return this.em.createNamedQuery(name, objClass);
}

I don't use a persistence.xml!

The stacktrace looks like this:

[ObjectDB 2.3.6] javax.persistence.PersistenceException
Type com.easyeng.rulesengine.interfaces.IRuleValueNode is not found (error 301)
at com.objectdb.jpa.EMImpl.createNamedQuery(EMImpl.java:828)
at com.dbservice.objectdb.DbServiceObjectDb.createNamedQuery(DbServiceObjectDb.java:157)
at com.dbservice.DbService.createNamedQuery(DbService.java:137)
at com.rulesengine.ifimpl.RulesEngineService.createOrFetchRoot(RulesEngineService.java:207)
at com.rulesengine.ifimpl.RulesEngineService.<init>(RulesEngineService.java:70)
at com.rulesengine.test.RulesEngineTestSystem.test(RulesEngineTestSystem.java:64)
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:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
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:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
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:601)
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:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
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:601)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Caused by: com.objectdb.o.TEX: Type com.rulesengine.interfaces.IRuleValueNode is not found
at com.objectdb.o.MSG.e(MSG.java:107)
at com.objectdb.o.TYM.ay(TYM.java:1005)
at com.objectdb.o.TYM.aq(TYM.java:818)
at com.objectdb.o.UTY.R(UTY.java:281)
at com.objectdb.o.UTY.<init>(UTY.java:205)
at com.objectdb.o.TYS.n(TYS.java:283)
at com.objectdb.o.TYM.ae(TYM.java:512)
at com.objectdb.o.TYM.ac(TYM.java:458)
at com.objectdb.o.TYM.ao(TYM.java:777)
at com.objectdb.jpa.EMImpl.loadResultType(EMImpl.java:880)
at com.objectdb.jpa.EMImpl.createNamedQuery(EMImpl.java:810)
... 57 more
Caused by: java.lang.ClassNotFoundException: com.rulesengine.interfaces.IRuleValueNode
at com.objectdb.o.TYM.findClass(TYM.java:1021)
at com.objectdb.o.ACL.loadClass(ACL.java:136)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at com.objectdb.o.TYM.ay(TYM.java:1001)
... 66 more

If I start my application with normal JUnit test everything works fine.

Thanks for your help

Peter

#4

Try setting the current thread context class loader before working with ObjectDB:

    Thread.currentThread().setContextClassLoader(IRuleValueNode.class.getClassLoader());

In addition, try version 2.4.1 instead of 2.3.6.

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

Hi,

Thanks, now I am one step closer. I get following stacktrace now:

java.lang.IllegalArgumentException: com.objectdb.o.UserException: Unknown named query 'RuleValueNode.findRoot' (no definition is found)
at com.objectdb.o.JPE.g(JPE.java:109)
at com.objectdb.o.ERR.f(ERR.java:60)
at com.objectdb.o.OBC.onObjectDBError(OBC.java:1504)
at com.objectdb.jpa.EMImpl.createNamedQuery(EMImpl.java:826)
at com.easyeng.dbservice.objectdb.DbServiceObjectDb.createNamedQuery(DbServiceObjectDb.java:160)
at com.easyeng.dbservice.DbService.createNamedQuery(DbService.java:137)
at com.easyeng.rulesengine.ifimpl.RulesEngineService.createOrFetchRoot(RulesEngineService.java:217)
at com.easyeng.rulesengine.ifimpl.RulesEngineService.<init>(RulesEngineService.java:78)
at com.easyeng.rulesengine.test.RulesEngineTestSystem.test(RulesEngineTestSystem.java:64)
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:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
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:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
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:601)
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:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
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:601)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Caused by: com.objectdb.o.UserException: Unknown named query 'RuleValueNode.findRoot' (no definition is found)
at com.objectdb.o.MSG.d(MSG.java:61)
at com.objectdb.o.TYM.aE(TYM.java:1249)
at com.objectdb.jpa.EMImpl.createNamedQuery(EMImpl.java:809)
... 57 more

Thanks for your help,

Peter

#6

Maybe that named query is defined in a class that ObjectDB doesn't know yet.

Please read the end of this manual page.

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

It works now! The problem was that I had have imported javax.persistence from eclipse plugins and not from objectDb.

Thanks for you help

BR

Peter


Post Reply

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