5

I am trying to use Maven for managing the dependencies of my plug-in project. The dependencies are correctly stated in the POM.xml. Even though, I get the exception :

java.lang.NoClassDefFoundError

Is it the correct way for solving dependencies for an Eclipse plug-in project?

3
  • Which class is stated? Can you post significative stack trace and pom.xml? Meanwhile, take a look at this Why am I getting a NoClassDefFoundError in Java? Commented May 27, 2020 at 18:26
  • I am using Swagger-Parser, when I run my code from a main as a Java Application, it runs fine. But when I run it as a plug-in it doesn't. The class which is not found is java.lang.NoClassDefFoundError: io/swagger/v3/parser/OpenAPIV3Parser Commented May 27, 2020 at 18:45
  • Can you post how do you run it as a plugin, maven goal? Commented May 27, 2020 at 18:56

1 Answer 1

1

Eclipse plug-ins must use the Require-Bundle or Import-Package statements in the plug-in's MANIFEST.MF to specify their dependencies.

Plug-ins can only be dependent on other plug-ins.

If you want to use a jar which is not a plug-in it must be included in the plug-in and included in the Bundle-Classpath in the MANIFEST.MF. You will also have to update the build.properties file to include the jars in the plug-in build.

Example MANIFEST.MF extract that includes 3 jars in the plug-in:

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 Import-Package: javax.annotation;version="1.0.0", javax.inject;version="1.0.0", org.eclipse.e4.core.di.annotations 

Matching 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 
Sign up to request clarification or add additional context in comments.

4 Comments

There is no way to use maven then ?
I added the jars to the Bundle-Classpath. The Plug-in has no problems. Even though I still have the 'java.lang.NoClassDefFoundError'.
You can use Maven to do plug-in builds by using Eclipse Tycho. See for example this tutorial
You must make sure the jars are included in the built plugin - make sure the build.properties includes the jars.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.