orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

Invisible classes in OSGi environment

Open Dmitry-PlainID opened this issue 9 years ago • 17 comments

OrientDB Version: 2.2.27

Java Version: 1.8

OS: Mac os

After installing OrientDB in OSGi environment (I use karat 4.1.2) I stuck with some problems:

  1. java.lang.NoClassDefFoundError: Could not initialize class com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal at com.orientechnologies.orient.server.OSystemDatabase.init(OSystemDatabase.java:147) ~[?:?] at com.orientechnologies.orient.server.OSystemDatabase.(OSystemDatabase.java:44) ~[?:?] at com.orientechnologies.orient.server.OServer.initSystemDatabase(OServer.java:1290) ~[?:?] at com.orientechnologies.orient.server.OServer.activate(OServer.java:352) ~[?:?]

    To fix it I removed static section in ODatabaseRecordThreadLocal class.

  2. Because I use Embedded & Distributed mode, orientdb-core indirectly uses orientdb-distributed module. In particular classes from com.orientechnologies.orient.server.distributed.impl, com.orientechnologies.orient.server.distributed.impl.task packages, that is not exportable. To fix it I added “,com.orientechnologies.orient.server.distributed.impl.*” in <osgi.export> property of orientdb-distributed
    pom.xml and “com.orientechnologies.orient.server.distributed.impl;resolution:=optional, com.orientechnologies.orient.server.distributed.impl.task;resolution:=optional,” in <osgi.import> property of orientdb-core
    pom.xml

Now bundles started and database synchronized with remote node. Could you add those changes to next version.

Dmitry-PlainID avatar Sep 26 '17 09:09 Dmitry-PlainID

@Dmitry-PlainID the second part is OK for me, what about the first part? Did you remove static initializer right? I am afraid that this change is not safe. Why did you do that?

andrii0lomakin avatar Sep 26 '17 12:09 andrii0lomakin

First, it fix a problem with NoClassDefFound exception (I don't know how, but it fact) Second, INSTANCE already initialized - ODatabaseRecordThreadLocal INSTANCE = new ODatabaseRecordThreadLocal(); This code do nothing

Dmitry-PlainID avatar Sep 27 '17 08:09 Dmitry-PlainID

@Dmitry-PlainID , it is already initialized in your application lifecycle, but some applications can startup and shutdown OrientDB engine several times. Could you send me your OSGi deployment so I will run it?

andrii0lomakin avatar Sep 27 '17 09:09 andrii0lomakin

I use Karaf 4.1.2 as OSGi framework.

This is very simple test project, that contains Activator and TestCommand. test-orientdb.tar.gz

Change in Activator ORIENTDB_HOME on you path.

Install OrientDB modules/bundels and its dependences. It's not simple, I used for it karaf feature project. orientdb-feature.zip

Build it - mvn install

Start karaf - bin/karaf.sh add repository - feature:repo-add mvn:com.test/orientdb-features/0.0.1-SNAPSHOT/xml/features install the feature - feature:install orientdb-features

Install my simple test bundle - install -s mvn:com.test/test-orientdb/0.0.1-SNAPSHOT

Dmitry-PlainID avatar Sep 27 '17 10:09 Dmitry-PlainID

No more answers?

Dmitry-PlainID avatar Oct 18 '17 12:10 Dmitry-PlainID

@Dmitry-PlainID we are busy by issues with higher priority once we finish them we will back to this one )).

andrii0lomakin avatar Oct 18 '17 13:10 andrii0lomakin

@Dmitry-PlainID I have tried to build project which you provided. But as result I have got:

 Bundle com.test:test-orientdb:bundle:0.0.1-SNAPSHOT : Error during loading properties file: /C:/Users/andrey/Documents/Development/test-orientdb, error:java.util.UnknownFormatConversionException: Conversion = '▒'

could you help me to fix that?

andrii0lomakin avatar Oct 19 '17 14:10 andrii0lomakin

Instead of junk in osgi.bnd(it should not be binary file) put following text: Bundle-Activator: com.test.orientdb.activator.Activator DynamicImport-Package: *

Dmitry-PlainID avatar Oct 19 '17 17:10 Dmitry-PlainID

@Dmitry-PlainID now I have got following error, could you help me to resolve it?

karaf@root()> feature:repo-add mvn:com.test/orientdb-features/0.0.1-SNAPSHOT/xml/features
Adding feature url mvn:com.test/orientdb-features/0.0.1-SNAPSHOT/xml/features
karaf@root()> feature:install orientdb-features
Error executing command: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=orientdb-features; type=karaf.feature; version="[0.0.1.SNAPSHOT,0.0.1.SNAPSHOT]"; filter:="(&(osgi.identity=orientdb-features)(type=karaf.feature)(version>=0.0.1.SNAPSHOT)(version<=0.0.1.SNAPSHOT))" [caused by: Unable to resolve orientdb-features/0.0.1.SNAPSHOT: missing requirement [orientdb-features/0.0.1.SNAPSHOT] osgi.identity; osgi.identity=com.orientechnologies.orientdb-graphdb; type=osgi.bundle; version="[2.2.27,2.2.27]"; resolution:=mandatory [caused by: Unable to resolve com.orientechnologies.orientdb-graphdb/2.2.27: missing requirement [com.orientechnologies.orientdb-graphdb/2.2.27] osgi.wiring.package; filter:="(osgi.wiring.package=org.apache.commons.configuration)" [caused by: Unable to resolve org.apache.commons.configuration/1.6.0: missing requirement [org.apache.commons.configuration/1.6.0] osgi.wiring.package; filter:="(osgi.wiring.package=javax.servlet)"]]]

andrii0lomakin avatar Oct 20 '17 12:10 andrii0lomakin

Perhaps I used pre-configured environment.

Run following steps: feature:install webconsole

feature:install pax-http-whiteboard

install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ant/1.7.0_6 install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-lang/2.4_6 install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-configuration/1.9_2 install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-beanutils/1.8.3_2 install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-jxpath/1.3_1

feature:repo-add mvn:com.test/orientdb-features/0.0.1-SNAPSHOT/xml/features feature:install orientdb-features

Dmitry-PlainID avatar Oct 20 '17 14:10 Dmitry-PlainID

@Dmitry-PlainID it is fixed in 2.2.x, could you build the latest snapshot from 2.2.x branch and check it?

andrii0lomakin avatar Oct 24 '17 15:10 andrii0lomakin

I checked, it works. Thanks.

Dmitry-PlainID avatar Oct 25 '17 09:10 Dmitry-PlainID

@Dmitry-PlainID could you try again ?

andrii0lomakin avatar Oct 25 '17 17:10 andrii0lomakin

need to reopen issue because of binary compatibility issues I will provide new version very soon.

andrii0lomakin avatar Oct 25 '17 17:10 andrii0lomakin

@Dmitry-PlainID could you try again ?

andrii0lomakin avatar Oct 28 '17 08:10 andrii0lomakin

I checked, It still works

Dmitry-PlainID avatar Oct 29 '17 09:10 Dmitry-PlainID

@Dmitry-PlainID thank you very much for the help. We plan to release 2.2.30 in two weeks, of course, this fix will be included.

andrii0lomakin avatar Oct 29 '17 12:10 andrii0lomakin