Search code examples
javabuildosgiclassnotfoundexception

ClassNotFoundException on resolved OSGI bundle


I have a little problem with a software solution I'm maintaining. We have previously moved the entire solution from Java 1.7 to Java 1.8 and are finally having most things run again.

Now I have encountered a problem. In my built product a certain class seems to be unable to load. This class comes from a bundle in a jar, which is a required-Bundle in the manifest of the calling bundle.

Weirdly enough the bundle seems to be resolved when starting the osgi environment, so I suppose the .jar is found correctly. Once the program tries to load a certain dialogue though, I get a ClassNotFoundException.

Within my IDE the dialogue works flawlessy, just the built product doesn't seem to be able to load the class at runtime (even though the bundle containing it resolves).

A graphic representation of what's happening:

+-----------------------+   +---------------------------+
|xtext....jar           |   |MyProject                  |
|.                      |   |.                          |
|.                      |   |.                          |    +-------------------------+
|.                      |   | MANIFEST.MF               |    |ClassNotFoundException   |
|  MANIFEST.MF          +---> -Bundle-Name:MyBundle     +--->+at runtime in built      |
|  -Bundle-Name:X-Bundle|   | -Require-Bundle:X-Bundle  |    +version                  |
|  -Export-Package:x    |   |                           |    +-------------------------+
|.                      |   |                           |
|.                      |   +---------------------------+
|DeltaConverter.class   |
|                       |
+-----------------------+

The class DeltaConverter is not found in the built version at runtime, although the bundle is resolved and I have a require bundle in place for the bundle using it.

Any hints, what could be happening here?


Solution

  • It seems to work now. The issue disappeared, when I tried to fix an issue I thought was unrelated to this one. I had 2 seemingly unrelated jar files (org.objectweb.asm_3.3.1 and org.objectweb.asm_5.0.1) on our build server. The build was using the older version which I then deleted from the build server, so it can only use the newer one. After changing this, everything seems to work now, even though I really don't why this solved the issue. Weird is, that neither this jar, nor any of the packages or classes contained in this jar where directly mentioned in the stacktraces I received from my Exceptions.