I am using a lib which communicates with another application through some native connection.
I have no sourcecode whatsoever of this lib, so i cant really specify how the application actually communicates.
Anyway, it works pretty well and i can communicate to the application. With this lib i can listen for events that happen in the other application. I can register for events and a listener is called with a special event-class.
Using OSGi, this event-class fails to load with the java.lang.NoClassDefFoundError
exception. Every Event is triggered in its own new thread. The package is imported correctly, and i can use the class throughout my code.
The Library i use is the HACL library by IBM.
Is this a problem of the API? or is it because of how native Events are handled? Can i somehow make the OSGi Classloader known to those new Threads?
Thanks.
The full stack trace is:
Exception in thread "Thread-20" java.lang.NoClassDefFoundError: com/ibm/eNetwork/ECL/event/ECLPSEvent
Caused by: java.lang.ClassNotFoundException: com.ibm.eNetwork.ECL.event.ECLPSEvent
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
First of all: I don't know the IBM product you are using, but only making suggestions from other external libraries I used in OSGi.
The suggested way to go is to include all the jars that are needed for the external library to work into your own bundle (common solution is to put them in a separate folder) and extend your bundle classpath to adapt this situation. Note that you need to specify all the jars here. Example:
You product consists of "a.jar" and "b.jar" and you copied them to the lib/ directory in your bundle, then the bundle class path must be:
assuming that your own code goes to the root of the bundle jar.
Common mistakes:
All these will result in some kind of ClassNotFoundException. My impression is that in your situation, the problem may be due to 1.