1
votes

I am getting Eclipse plugin: java.lang.NoClassDefFoundError for org/jongo/ResultHandler

My source code compiled successfully after adding the necessary jar files.I have added these jars using project>build path as Reference libraries in Eclipse.

Now the problem is these external jar files are not working during Runtime.

My MANIFEST.MF file has only one jar, not the external jars. Don't know how to add external jars here.

Bundle-ClassPath: Test.jar

Build.properties

source.Test.jar = src/
bin.includes = plugin.xml,\
               META-INF/,\
               Test.jar

Please suggest how to run my app at runtime which will look external jars.

1
Is the not found jar an OSGi bundle? In case yes, you should not add the jar to the included jars, but to the dependencies. In case no, you should also add it to the bin.includes part of build.properties.Gábor Bakos
Thank you. It's working now :)Ronak

1 Answers

3
votes

Never add jars directly to the build path when creating plugins.

You must include all jars in your plugin (or as other plugins) and set the Bundle-Classpath and include the jars in the build.properties. If you are referencing other plugins just add them the your plugin's dependencies.

You can add them to the MANIFEST.MF using the MANIFEST.MF/plugin.xml/build.properties editor.

On the editor 'Runtime' tab add the jars to the 'Classpath' entries (there should also be a '.' entry for you main plugin code).

On the 'Build' tab of the editor check all jars you want to include in the plugin. You should put the jars somewhere in your plugin (a 'lib' directory for example).

For example, in this build.properties:

source.. = src/
output.. = bin/
bin.includes = META-INF/,\
               .,\
               plugin.properties,\
               plugin.xml,\
               lib/jogg-0.0.7.jar,\
               lib/jorbis-0.0.15.jar,\
               lib/vorbisspi1.0.2.jar,\
               icons/

I have three jars in a 'lib' directory.

The MANIFEST.MF for this looks like:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: greg.music.ogg;singleton:=true
Bundle-Version: 2.0.0.qualifier
Bundle-Vendor: %plugin.provider
Bundle-Localization: plugin
Require-Bundle: greg.music.core;bundle-version="1.0.0",
 greg.music.resources;bundle-version="1.0.0",
 org.eclipse.core.runtime,
 javazoom.jlgui.basicplayer,
 org.eclipse.e4.core.services;bundle-version="2.0.100"
Bundle-ClassPath: .,
 lib/jogg-0.0.7.jar,
 lib/jorbis-0.0.15.jar,
 lib/vorbisspi1.0.2.jar
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: javax.annotation;version="1.0.0",
 javax.inject;version="1.0.0",
 org.eclipse.e4.core.di.annotations

Runtime tab in editor: enter image description here

Build tab: enter image description here