views:

591

answers:

3

I am creating a plugin which requires jdt.ui.JavaUI class. I included the jdt.ui plugin into the dependencies. This is my Manifest.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: PanelGenerator Plug-in
Bundle-SymbolicName: PanelGeneratorPlugin; singleton:=true
Bundle-Version: 0.1.0
Bundle-Activator: panelgenerator.plugin.Activator
Require-Bundle: org.eclipse.jdt.core,
 org.eclipse.ui,
 org.eclipse.core.runtime,
 org.eclipse.core.resources,
 org.eclipse.ui.ide,
 org.eclipse.jdt.ui
Eclipse-LazyStart: true

and this is my build.properties:

source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
           META-INF/,\
           .,\
           icons/,\
           templates/

At compile time I do not get any compilation errors. If I debug the plugin using Eclipse (Debug as -> Eclipse Application) it works fine.

However when I export it, then install it copying it into the Eclipse plugins folder, the plugin does not work. As soon as the JavaUI class is used, nothing happens. The error log reports this:

java.lang.NoClassDefFoundError: org/eclipse/jdt/ui/JavaUI

Any ideas on why this is happening?

A: 

The only thing I can think of is perhaps you are compiling against different versions than you are running against and there are non-binary-compatible changes. You can see something similar in eclipse bug 177476 where this happened.

Andrew Niefer
A: 

The order of the plugins in "Require-Bundle" is important! You should order them in a way such that the most basic ones come first.

I would suggest:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: PanelGenerator Plug-in
Bundle-SymbolicName: PanelGeneratorPlugin; singleton:=true
Bundle-Version: 0.1.0
Bundle-Activator: panelgenerator.plugin.Activator
Require-Bundle:  org.eclipse.core.runtime,
 org.eclipse.core.resources,
 org.eclipse.jdt.core,
 org.eclipse.ui,
 org.eclipse.ui.ide,
 org.eclipse.jdt.ui
Eclipse-LazyStart: true

This is because eclipse loads the classes from the bundles in the order you provided. This may cause trouble if the order is not from "basic" to "non-basic". Try this, it might help.

Arne
A: 

Which version of Eclipse are you trying this with? If you are using 3.4 (Ganymede) or 3.5 (Galileo), you can't just add new plugins to the plugins folder anymore. Try putting your plugin into the dropins folder instead (that is the intention of the dropins folder).

When your plugin is ready for a more permanent deployment, you can export it with P2 metadata and use the update manager to start it up.

If you're using an older version of Eclipse, the .log file will probably give you some details about the plugin.

Steve Robenalt