Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return of (fixed) 2.0 issue in 2.1/2.2: NoClassDefFoundError for ODatabaseRecordThreadLocal #6404

Closed
RoarN opened this issue Jul 11, 2016 · 30 comments
Assignees
Labels

Comments

@RoarN
Copy link

RoarN commented Jul 11, 2016

Windows 10, Orientdb 2.2.4

I'm trying to upgrade from 2.0 to 2.2.4 and ran into the same issue that I had when upgrading from 1.7 to 2.0.
We are running OSGI and are embedding all Orientdb bundles and their dependencies into our bundle.

I posted on the google group when I tried the same upgrade to 2.1.3 and got these answers from you guys: https://groups.google.com/d/msg/orient-database/gjkfiywvIvs/4g0O0pXNDAAJ
But it doesn't look like anyone actually did something...

2016-07-11 09:59:58,228 [Thread-3] ERROR com.aaa.bootstrap.OSGiLogger - com.aaa.orientdb [131]: [ERROR] : java.lang.NoClassDefFoundError: Could not initialize class com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal null
org.apache.felix.log.LogException: java.lang.IllegalStateException: java.lang.NoClassDefFoundError: Could not initialize class com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal
at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:171)
at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.stateChanged(LifecycleCallbackHandler.java)
at org.apache.felix.ipojo.InstanceManager.setState(InstanceManager.java:560)
at org.apache.felix.ipojo.InstanceManager.start(InstanceManager.java:440)
at org.apache.felix.ipojo.ComponentFactory.createInstance(ComponentFactory.java:179)
at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:319)
at org.apache.felix.ipojo.IPojoFactory.createComponentInstance(IPojoFactory.java:240)
at org.apache.felix.ipojo.extender.internal.linker.ManagedType$InstanceSupport$1.call(ManagedType.java:312)
at org.apache.felix.ipojo.extender.internal.linker.ManagedType$InstanceSupport$1.call(ManagedType.java:306)
at org.apache.felix.ipojo.extender.internal.queue.JobInfoCallable.call(JobInfoCallable.java:114)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.activateOnCurrentThread(ODatabaseDocumentTx.java:2966)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.(ODatabaseDocumentTx.java:157)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.(OPartitionedDatabasePool.java:118)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool$DatabaseDocumentTxPolled.(OPartitionedDatabasePool.java:114)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.initQueue(OPartitionedDatabasePool.java:442)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.(OPartitionedDatabasePool.java:217)
at com.ceesoft.ceeview.datastore.impl.blueprints.orientdb.DatabaseManagerProvider.__M_validate(DatabaseManagerProvider.java:190)
at com.ceesoft.ceeview.datastore.impl.blueprints.orientdb.DatabaseManagerProvider.validate(DatabaseManagerProvider.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.felix.ipojo.util.Callback.call(Callback.java:233)
at org.apache.felix.ipojo.util.Callback.call(Callback.java:193)
at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallback.call(LifecycleCallback.java:86)
at org.apache.felix.ipojo.handlers.lifecycle.callback.LifecycleCallbackHandler.__M_stateChanged(LifecycleCallbackHandler.java:162)
... 13 more

It took several versions of 2.0 before the issue was finally fixed. Since the issue now is back, does that mean that the bug fixes done late in 2.0 have not been merged into 2.1 or is there another reason that the problem has returned in 2.1?

Regards,
Roar

@RoarN
Copy link
Author

RoarN commented Aug 29, 2016

I see that 2.2.7 and 2.2.8 has been released in the mean time, any progress on this issue?

@taburet taburet self-assigned this Sep 8, 2016
@taburet
Copy link
Contributor

taburet commented Sep 8, 2016

Could you please test against the experimental OrientDB OSGi distribution as described here #6306 (comment)

@andrii0lomakin
Copy link
Member

Close issue because of no reply. If you reproduce given issue and have information which is requested in issue feel free to reopen it.

@andrii0lomakin andrii0lomakin removed this from the 2.2.x (next hotfix) milestone Sep 27, 2016
@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

Stopped actively following this case after more than a month with no activity and I didn't get any notification until the case was closed. But I have now tested the osgi bundle. The bundle it self worked just fine but the error during startup is the same:

2016-09-29 10:53:43,167 [Thread-3] ERROR com.ceesoft.ceeview.core.bootstrap.OSGiLogger - com.ceesoft.ceeview.datastore.impl.blueprints.orientdb [79]: [ERROR] : [com.ceesoft.ceeview.datastore.impl.blueprints.orientdb.DatabaseManagerProvider-0] The callback method validate has thrown an exception : javax/script/ScriptEngineFactory null
org.apache.felix.log.LogException: java.lang.NoClassDefFoundError: javax/script/ScriptEngineFactory
at com.orientechnologies.orient.core.Orient.(Orient.java:68)
at com.orientechnologies.orient.core.Orient.(Orient.java:60)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract.(ORecordSerializerStringAbstract.java:50)
at com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializerFactory.(ORecordSerializerFactory.java:48)
at com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializerFactory.(ORecordSerializerFactory.java:38)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.(ODatabaseDocumentTx.java:111)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.initQueue(OPartitionedDatabasePool.java:355)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.(OPartitionedDatabasePool.java:116)

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

I can't find a way to reopen this case.

@taburet taburet reopened this Sep 29, 2016
@taburet
Copy link
Contributor

taburet commented Sep 29, 2016

Reopened. It's a similar exception, but the cause is different. Do you manually start Felix or it's a part of some other external framework?

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

We manually starts an embedded Felix instance.

@taburet
Copy link
Contributor

taburet commented Sep 29, 2016

Did you tweak org.osgi.framework.bootdelegation or felix.bootdelegation.implicit Felix settings?

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

No, vanilla launch of Felix.

@taburet
Copy link
Contributor

taburet commented Sep 29, 2016

Please make sure that felix.bootdelegation.implicit is true. If this won't help, try to set org.osgi.framework.bootdelegation to javax.*.

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

first one didn't help. the second triggered this exception:

org.apache.felix.log.LogException: java.lang.NoClassDefFoundError: sun/misc/Unsafe
at com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8.getUnsafe(ConcurrentHashMapV8.java:4136)
at com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8.(ConcurrentHashMapV8.java:4101)
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.(ConcurrentLinkedHashMap.java:221)
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.(ConcurrentLinkedHashMap.java:104)
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap$Builder.build(ConcurrentLinkedHashMap.java:1634)
at com.orientechnologies.common.profiler.OProfilerStub.(OProfilerStub.java:38)
at com.orientechnologies.orient.core.Orient.startup(Orient.java:208)
at com.orientechnologies.orient.core.Orient.(Orient.java:98)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract.(ORecordSerializerStringAbstract.java:50)
at com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializerFactory.(ORecordSerializerFactory.java:48)
at com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializerFactory.(ORecordSerializerFactory.java:38)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.(ODatabaseDocumentTx.java:111)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.initQueue(OPartitionedDatabasePool.java:355)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.(OPartitionedDatabasePool.java:116)

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

Followed the original exception down one level and found this (more details about the class):

Caused by: java.lang.ClassNotFoundException: javax.script.ScriptEngineFactory not found by orientdb-osgi-core-bundle [111]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

@taburet
Copy link
Contributor

taburet commented Sep 29, 2016

Well, set it to javax.*,sun.misc.*,com.sun.*. That's all because Felix's smart automatic system package resolution procedure (felix.bootdelegation.implicit=true) failed to recognise javax.script.ScriptEngineFactory as a system class which is a de facto standard now. So we have to tune the org.osgi.framework.bootdelegation manually.

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

Looks like sun.misc.Unsafe was not found even though sun.misc.* was set.

Exception:
org.apache.felix.log.LogException: java.lang.NoClassDefFoundError: sun/misc/Unsafe
at com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8.getUnsafe(ConcurrentHashMapV8.java:4136)
at com.googlecode.concurrentlinkedhashmap.ConcurrentHashMapV8.(ConcurrentHashMapV8.java:4101)
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.(ConcurrentLinkedHashMap.java:221)
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.(ConcurrentLinkedHashMap.java:104)
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap$Builder.build(ConcurrentLinkedHashMap.java:1634)
at com.orientechnologies.common.profiler.OProfilerStub.(OProfilerStub.java:38)
at com.orientechnologies.orient.core.Orient.startup(Orient.java:208)
at com.orientechnologies.orient.core.Orient.(Orient.java:98)
at com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract.(ORecordSerializerStringAbstract.java:50)
at com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializerFactory.(ORecordSerializerFactory.java:48)
at com.orientechnologies.orient.core.serialization.serializer.record.ORecordSerializerFactory.(ORecordSerializerFactory.java:38)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.(ODatabaseDocumentTx.java:111)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.initQueue(OPartitionedDatabasePool.java:355)
at com.orientechnologies.orient.core.db.OPartitionedDatabasePool.(OPartitionedDatabasePool.java:116)
at com.ceesoft.ceeview.datastore.impl.blueprints.orientdb.DatabaseManagerProvider.__M_validate(DatabaseManagerProvider.java:189)
at com.ceesoft.ceeview.datastore.impl.blueprints.orientdb.DatabaseManagerProvider.validate(DatabaseManagerProvider.java)

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

Took a dump of our exported packages from system bundle without your changes.
javax.script is already a part of this, but we still get an exception.

Exported Packages
javax.accessibility,version=0.0.0.1_008_JavaSE
javax.activation,version=0.0.0.1_008_JavaSE
javax.activity,version=0.0.0.1_008_JavaSE
javax.annotation,version=0.0.0.1_008_JavaSE
javax.annotation.processing,version=0.0.0.1_008_JavaSE
javax.crypto,version=0.0.0.1_008_JavaSE
javax.crypto.interfaces,version=0.0.0.1_008_JavaSE
javax.crypto.spec,version=0.0.0.1_008_JavaSE
javax.imageio,version=0.0.0.1_008_JavaSE
javax.imageio.event,version=0.0.0.1_008_JavaSE
javax.imageio.metadata,version=0.0.0.1_008_JavaSE
javax.imageio.plugins.bmp,version=0.0.0.1_008_JavaSE
javax.imageio.plugins.jpeg,version=0.0.0.1_008_JavaSE
javax.imageio.spi,version=0.0.0.1_008_JavaSE
javax.imageio.stream,version=0.0.0.1_008_JavaSE
javax.jws,version=0.0.0.1_008_JavaSE
javax.jws.soap,version=0.0.0.1_008_JavaSE
javax.lang.model,version=0.0.0.1_008_JavaSE
javax.lang.model.element,version=0.0.0.1_008_JavaSE
javax.lang.model.type,version=0.0.0.1_008_JavaSE
javax.lang.model.util,version=0.0.0.1_008_JavaSE
javax.management,version=0.0.0.1_008_JavaSE
javax.management.loading,version=0.0.0.1_008_JavaSE
javax.management.modelmbean,version=0.0.0.1_008_JavaSE
javax.management.monitor,version=0.0.0.1_008_JavaSE
javax.management.openmbean,version=0.0.0.1_008_JavaSE
javax.management.relation,version=0.0.0.1_008_JavaSE
javax.management.remote,version=0.0.0.1_008_JavaSE
javax.management.remote.rmi,version=0.0.0.1_008_JavaSE
javax.management.timer,version=0.0.0.1_008_JavaSE
javax.naming,version=0.0.0.1_008_JavaSE
javax.naming.directory,version=0.0.0.1_008_JavaSE
javax.naming.event,version=0.0.0.1_008_JavaSE
javax.naming.ldap,version=0.0.0.1_008_JavaSE
javax.naming.spi,version=0.0.0.1_008_JavaSE
javax.net,version=0.0.0.1_008_JavaSE
javax.net.ssl,version=0.0.0.1_008_JavaSE
javax.print,version=0.0.0.1_008_JavaSE
javax.print.attribute,version=0.0.0.1_008_JavaSE
javax.print.attribute.standard,version=0.0.0.1_008_JavaSE
javax.print.event,version=0.0.0.1_008_JavaSE
javax.rmi,version=0.0.0.1_008_JavaSE
javax.rmi.CORBA,version=0.0.0.1_008_JavaSE
javax.rmi.ssl,version=0.0.0.1_008_JavaSE
javax.script,version=0.0.0.1_008_JavaSE
javax.security.auth,version=0.0.0.1_008_JavaSE
javax.security.auth.callback,version=0.0.0.1_008_JavaSE
javax.security.auth.kerberos,version=0.0.0.1_008_JavaSE
javax.security.auth.login,version=0.0.0.1_008_JavaSE
javax.security.auth.spi,version=0.0.0.1_008_JavaSE
javax.security.auth.x500,version=0.0.0.1_008_JavaSE
javax.security.cert,version=0.0.0.1_008_JavaSE
javax.security.sasl,version=0.0.0.1_008_JavaSE
javax.sound.midi,version=0.0.0.1_008_JavaSE
javax.sound.midi.spi,version=0.0.0.1_008_JavaSE
javax.sound.sampled,version=0.0.0.1_008_JavaSE
javax.sound.sampled.spi,version=0.0.0.1_008_JavaSE
javax.sql,version=0.0.0.1_008_JavaSE
javax.sql.rowset,version=0.0.0.1_008_JavaSE
javax.sql.rowset.serial,version=0.0.0.1_008_JavaSE
javax.sql.rowset.spi,version=0.0.0.1_008_JavaSE
javax.swing,version=0.0.0.1_008_JavaSE
javax.swing.border,version=0.0.0.1_008_JavaSE
javax.swing.colorchooser,version=0.0.0.1_008_JavaSE
javax.swing.event,version=0.0.0.1_008_JavaSE
javax.swing.filechooser,version=0.0.0.1_008_JavaSE
javax.swing.plaf,version=0.0.0.1_008_JavaSE
javax.swing.plaf.basic,version=0.0.0.1_008_JavaSE
javax.swing.plaf.metal,version=0.0.0.1_008_JavaSE
javax.swing.plaf.multi,version=0.0.0.1_008_JavaSE
javax.swing.plaf.nimbus,version=0.0.0.1_008_JavaSE
javax.swing.plaf.synth,version=0.0.0.1_008_JavaSE
javax.swing.table,version=0.0.0.1_008_JavaSE
javax.swing.text,version=0.0.0.1_008_JavaSE
javax.swing.text.html,version=0.0.0.1_008_JavaSE
javax.swing.text.html.parser,version=0.0.0.1_008_JavaSE
javax.swing.text.rtf,version=0.0.0.1_008_JavaSE
javax.swing.tree,version=0.0.0.1_008_JavaSE
javax.swing.undo,version=0.0.0.1_008_JavaSE
javax.tools,version=0.0.0.1_008_JavaSE
javax.transaction,version=0.0.0.1_008_JavaSE
javax.transaction.xa,version=0.0.0.1_008_JavaSE
javax.xml,version=0.0.0.1_008_JavaSE
javax.xml.bind,version=0.0.0.1_008_JavaSE
javax.xml.bind.annotation,version=0.0.0.1_008_JavaSE
javax.xml.bind.annotation.adapters,version=0.0.0.1_008_JavaSE
javax.xml.bind.attachment,version=0.0.0.1_008_JavaSE
javax.xml.bind.helpers,version=0.0.0.1_008_JavaSE
javax.xml.bind.util,version=0.0.0.1_008_JavaSE
javax.xml.crypto,version=0.0.0.1_008_JavaSE
javax.xml.crypto.dom,version=0.0.0.1_008_JavaSE
javax.xml.crypto.dsig,version=0.0.0.1_008_JavaSE
javax.xml.crypto.dsig.dom,version=0.0.0.1_008_JavaSE
javax.xml.crypto.dsig.keyinfo,version=0.0.0.1_008_JavaSE
javax.xml.crypto.dsig.spec,version=0.0.0.1_008_JavaSE
javax.xml.datatype,version=0.0.0.1_008_JavaSE
javax.xml.namespace,version=0.0.0.1_008_JavaSE
javax.xml.parsers,version=0.0.0.1_008_JavaSE
javax.xml.soap,version=0.0.0.1_008_JavaSE
javax.xml.stream,version=0.0.0.1_008_JavaSE
javax.xml.stream.events,version=0.0.0.1_008_JavaSE
javax.xml.stream.util,version=0.0.0.1_008_JavaSE
javax.xml.transform,version=0.0.0.1_008_JavaSE
javax.xml.transform.dom,version=0.0.0.1_008_JavaSE
javax.xml.transform.sax,version=0.0.0.1_008_JavaSE
javax.xml.transform.stax,version=0.0.0.1_008_JavaSE
javax.xml.transform.stream,version=0.0.0.1_008_JavaSE
javax.xml.validation,version=0.0.0.1_008_JavaSE
javax.xml.ws,version=0.0.0.1_008_JavaSE
javax.xml.ws.handler,version=0.0.0.1_008_JavaSE
javax.xml.ws.handler.soap,version=0.0.0.1_008_JavaSE
javax.xml.ws.http,version=0.0.0.1_008_JavaSE
javax.xml.ws.soap,version=0.0.0.1_008_JavaSE
javax.xml.ws.spi,version=0.0.0.1_008_JavaSE
javax.xml.ws.spi.http,version=0.0.0.1_008_JavaSE
javax.xml.ws.wsaddressing,version=0.0.0.1_008_JavaSE
javax.xml.xpath,version=0.0.0.1_008_JavaSE
org.ietf.jgss,version=0.0.0.1_008_JavaSE
org.omg.CORBA,version=0.0.0.1_008_JavaSE
org.omg.CORBA.DynAnyPackage,version=0.0.0.1_008_JavaSE
org.omg.CORBA.ORBPackage,version=0.0.0.1_008_JavaSE
org.omg.CORBA.TypeCodePackage,version=0.0.0.1_008_JavaSE
org.omg.CORBA.portable,version=0.0.0.1_008_JavaSE
org.omg.CORBA_2_3,version=0.0.0.1_008_JavaSE
org.omg.CORBA_2_3.portable,version=0.0.0.1_008_JavaSE
org.omg.CosNaming,version=0.0.0.1_008_JavaSE
org.omg.CosNaming.NamingContextExtPackage,version=0.0.0.1_008_JavaSE
org.omg.CosNaming.NamingContextPackage,version=0.0.0.1_008_JavaSE
org.omg.Dynamic,version=0.0.0.1_008_JavaSE
org.omg.DynamicAny,version=0.0.0.1_008_JavaSE
org.omg.DynamicAny.DynAnyFactoryPackage,version=0.0.0.1_008_JavaSE
org.omg.DynamicAny.DynAnyPackage,version=0.0.0.1_008_JavaSE
org.omg.IOP,version=0.0.0.1_008_JavaSE
org.omg.IOP.CodecFactoryPackage,version=0.0.0.1_008_JavaSE
org.omg.IOP.CodecPackage,version=0.0.0.1_008_JavaSE
org.omg.Messaging,version=0.0.0.1_008_JavaSE
org.omg.PortableInterceptor,version=0.0.0.1_008_JavaSE
org.omg.PortableInterceptor.ORBInitInfoPackage,version=0.0.0.1_008_JavaSE
org.omg.PortableServer,version=0.0.0.1_008_JavaSE
org.omg.PortableServer.CurrentPackage,version=0.0.0.1_008_JavaSE
org.omg.PortableServer.POAManagerPackage,version=0.0.0.1_008_JavaSE
org.omg.PortableServer.POAPackage,version=0.0.0.1_008_JavaSE
org.omg.PortableServer.ServantLocatorPackage,version=0.0.0.1_008_JavaSE
org.omg.PortableServer.portable,version=0.0.0.1_008_JavaSE
org.omg.SendingContext,version=0.0.0.1_008_JavaSE
org.omg.stub.java.rmi,version=0.0.0.1_008_JavaSE
org.osgi.dto,version=1.0.0
org.osgi.framework,version=1.8.0
org.osgi.framework.dto,version=1.8.0
org.osgi.framework.hooks.bundle,version=1.1.0
org.osgi.framework.hooks.resolver,version=1.0.0
org.osgi.framework.hooks.service,version=1.1.0
org.osgi.framework.hooks.weaving,version=1.1.0
org.osgi.framework.launch,version=1.2.0
org.osgi.framework.namespace,version=1.1.0
org.osgi.framework.startlevel,version=1.0.0
org.osgi.framework.startlevel.dto,version=1.0.0
org.osgi.framework.wiring,version=1.2.0
org.osgi.framework.wiring.dto,version=1.2.0
org.osgi.resource,version=1.0.0
org.osgi.resource.dto,version=1.0.0
org.osgi.service.packageadmin,version=1.2.0
org.osgi.service.resolver,version=1.0.0
org.osgi.service.startlevel,version=1.1.0
org.osgi.service.url,version=1.0.0
org.osgi.util.tracker,version=1.5.1
org.w3c.dom,version=0.0.0.1_008_JavaSE
org.w3c.dom.bootstrap,version=0.0.0.1_008_JavaSE
org.w3c.dom.events,version=0.0.0.1_008_JavaSE
org.w3c.dom.ls,version=0.0.0.1_008_JavaSE
org.xml.sax,version=0.0.0.1_008_JavaSE
org.xml.sax.ext,version=0.0.0.1_008_JavaSE
org.xml.sax.helpers,version=0.0.0.1_008_JavaSE
sun.misc,version=0.0.0
sun.net.util,version=0.0.0
sun.reflect,version=0.0.0

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

The only import package by orientdb-osgi-core-bundle is 'org.osgi.framework,version=1.8.0 from org.apache.felix.framework (0)'

You should explicitly import all needed packages according to my Felix guy :)

@taburet
Copy link
Contributor

taburet commented Sep 29, 2016

He is partially right :) All non-boot delegated packages should be imported. The only non-boot delegated dependency of orientdb-osgi-core-bundle is org.osgi.framework. The problem is somewhere else.

@taburet
Copy link
Contributor

taburet commented Sep 29, 2016

Please elaborate more on the exported packages listing you provided. How you obtained them? Are they re-exported from some bundle in your setup?

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

The list was obtained using Apache Felix Web Console and lists packages exported by the 'System Bundle'

@taburet
Copy link
Contributor

taburet commented Sep 29, 2016

BTW, do you manually tweak the org.osgi.framework.system.packages or org.osgi.framework.system.packages.extra?

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

config.put("org.osgi.framework.system.packages.extra", "sun.misc,sun.net.util,sun.reflect");

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

Did some changes to the pom.xml to get past the ScriptEngineFactory issue by adding this to orientdb-osgi-core-bundle:

org.osgi.framework,javax.script,sun.misc

This actually fixed the javax.script issue and sun.misc issue and I'm back to ODatabaseRecordThreadLocal exception that started this case :)

java.lang.NoClassDefFoundError: Could not initialize class com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.activateOnCurrentThread(ODatabaseDocumentTx.java:3026)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.(ODatabaseDocumentTx.java:160)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.(ODatabaseDocumentTx.java:151)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.openOrCreate(OrientBaseGraph.java:1974)
at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.(OrientBaseGraph.java:162)
at com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx.(OrientGraphNoTx.java:72)

@taburet
Copy link
Contributor

taburet commented Sep 29, 2016

Oh, I see. A package can't be boot delegated and system bundle exported at the same time. Seems like system bundle exported one has a priority. That's why it's unable to resolve the Unsafe.

Regarding the ODatabaseRecordThreadLocal problem. According the original exception stack trace, there are iPojo components and some kind of a ThreadPoolExecutor involved, they both may do tricks with the class loading. Seems like the class loader is wrong or it's somehow restricted to only some subset of the packages. But why it is so, that is the question :)

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

Here is the complete import block for orientdb-osgi-core-bundle:

<Import-Package> org.osgi.framework,javax.script,javax.management,javax.naming,javax.naming.directory,javax.net,javax.net.ssl,javax.crypto,javax.crypto.spec,sun.misc
</Import-Package>

There is still a timing issue, but I will describe that in the a new comment

@RoarN
Copy link
Author

RoarN commented Sep 29, 2016

First creation of a connection in a OSGI service will fail e.g.
OrientGraph graph = new OrientGraph(url, user, password);

ODatabaseRecordThreadLocal line 32, Orient.instance() is null first time it is called.
Adding a test fixes the problem for the first connection:

    final Orient inst = Orient.instance();
    if(inst != null) {
    }

The same line triggers the creation of the global Orient object so all following connections will work.

So with the if-test the following code works with the test above in place. Of course the first connection can not be used.

@Validate
public void validate()
{
 OrientGraph graph = new OrientGraph(url, user, password);
 Thread.sleep(1000);
 OrientGraph graph = new OrientGraph(url, user, password);
}

Creating a dummy connection to initialize Orient is not a permanent solution. So we need to figure out how to make the bundle create the global Orient Object by it self. I don't think this is a issue when using Orient from an application so it must be related to the loading of bundles and/or class path.

@RoarN
Copy link
Author

RoarN commented Oct 4, 2016

I went back to testing using Import-Package on orient-graphdb again with 2.2.12-SNAPSHOT.

ODatabaseRecordThreadLocal line 31, when called the first time Orient.instance() returns null.

Adding the following null pointer test actually removes the initial ClassNotFound exception

if(inst != null){
    inst.registerListener(new OOrientListenerAbstract() {

Consecutive calls that creates ODatabaseRecordThreadLocal will work and thus "fixing" the issue.
However I have no idea about what side effect skipping registerListener will have on the application.
The static Orient instance is created some time later and Orient.instance() will return an object if called at a later time.

So my conclusion is that #3501 didn't fix the issue but just hid it with the null pointer test like I did above, thus "fixing" the issue in 2.0.
The change that broke it again seems to be #4537 that removed the if (inst != null) check.

It seems like running Orient in a OSGI bundle messes up the loading of static constructors somehow. But why it results in ClassNotFound exceptions I have no idea.

@taburet
Copy link
Contributor

taburet commented Oct 7, 2016

@RoarN do you have a link to the previous issue when it was resolved in the first time?

Unfortunately, we are dropping the support of osgi-2.2.x branch, more information here.

@taburet
Copy link
Contributor

taburet commented Oct 7, 2016

Sorry, found the link :)

@RoarN
Copy link
Author

RoarN commented Dec 8, 2016

SOLUTION:
We are using Apache Felix iPOJO as our service component model.
On a whim we decided to use the standard OSGI Bundle Activator instead of iPOJO validate method to initialize OrientDB and to our surprise everything worked.
We have at least 100 services implemented using iPOJO so we have no idea why it causes problems when used together with OrientDB, but we suspect that it messes with the class loader somehow.

@RoarN RoarN closed this as completed Dec 8, 2016
@rareddy
Copy link

rareddy commented Aug 15, 2017

IMO, this issue is never fixed. The root cause of the issue I think is about class loader "ScriptEngineManager" uses in [1], which is boot/root class loader, i.e. if there are any script engines that are added using a dynamic class loader they will never be loaded. The correct way to do is on line 73 from [1] is

scriptEngineManager = new ScriptEngineManager(this.getClass().getClassloader());
or use thread context class loader. That is why you saw issues with systems like Felix above and I am facing with WildFly which have modular dynamic classloaders.

[1] https://github.com/orientechnologies/orientdb/blob/2.2.5/core/src/main/java/com/orientechnologies/orient/core/command/script/OScriptManager.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

5 participants