NoClassDefFoundError exception when using the external library in the EMF plug-in project

advertisements

I'm working on a EMF project where I've created a ecore model from a mdl file. I created the corresponding gencore file and generated the code from the gencore file. While EMF has a own serialization mechanism based on XMI I want to support my project with a own serializiation mechanism.

So far, I've done the necessary steps and if I use the debugger the corresponding methods are called. In order to read and write a file representation of my model I want to use an external library. I've done the following steps

  1. Created a directory lib/ in my plugin project where I've put the external library
  2. Added the library to the build path of the project
  3. Added the directory to the bundle-classpath (Manifest.mf)
  4. Added the directory to the bin.includes of the build.properties

If I try to run my code I get a NoClassDefFoundError exception and I don't know why. I've created a run configuration where I'm starting the project as a eclipse application. So somebody has an idea what I'm missing?

Thanks in advance!
Michael

Edit: Below my Manifest.mf file

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: de.hs_rm.cs.vs.dsm.OWL
Bundle-SymbolicName: de.hs_rm.cs.vs.dsm.owl;singleton:=true
Bundle-Version: 1.0.0
Bundle-ClassPath: lib/,
 .
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: owl,
 owl.impl,
 owl.util,
 rdfs,
 rdfs.impl,
 rdfs.util
Require-Bundle: org.eclipse.core.runtime,
 org.eclipse.emf.ecore;visibility:=reexport
Bundle-ActivationPolicy: lazy

and also my build.properties

bin.includes = .,\
               model/,\
               META-INF/,\
               plugin.xml,\
               plugin.properties,\
               lib/
jars.compile.order = lib/,\
                     .
source.. = src/
output.. = bin/
source.lib/ = lib/
jars.extra.classpath = lib/owlapi-bin.jar


it's not really a hundred percent solution since I'm not aware what exactly the problem was at all. I've found a link where somebody had the exactly same problem (added a jar as library, NoClassDefFoundError exception during execution). So far, the necessary steps are:

  1. Import JARs using the "Import -> File System"
  2. Add the JAR-file(s) to the classpath section of the Manifest/plugin.xml runtime tab
  3. Press "New..." to add "." library back to the classpath
  4. Check that the binary build exports the new JAR-file(s) on the Build tab
  5. Press save
  6. Select the coressponding project in the project explorer view, right click and select "PDE Tools -> Update classpath". This will add the newly added JAR-file(s) to the project's classpath.

I've had some trouble with the last step since I've added the library by myself to the build path of the project. Every time I did this eclipse removed the library from the build path while executing the "Update classpath command". I've repeated step six without adding the library to the build path by myself and it's now working.

It seems a bit odd to me, but it's now working. Anyway I would like to thank you for your help!

Regards, Michael