Frage

I'm developing a plug-in that needs access to the class org.eclipse.swt.widgets.Display. This class is contained in org.eclipse.swt.win32.win32.x86_3.5.2.v3557f-RCP20100710-0200.jar. However, the class is also exported by the manifest in com.ibm.rcp.jfaceex_6.2.2.20100729-1241 as follows:

Export-Package: com.ibm.rcp.jface.action,com.ibm.rcp.jface.launcher,co
 m.ibm.rcp.jface.themes,com.ibm.rcp.jface.util,com.ibm.rcp.jface.viewe
 rs,com.ibm.rcp.jface.window,com.ibm.rcp.jface.window.effects,com.ibm.
 rcp.ui.widgets.api.jface,com.ibm.rcp.ui.widgets.api.swt
Require-Bundle: com.ibm.rcp.swtex,org.eclipse.swt,org.eclipse.core.run
 time,org.eclipse.jface,org.eclipse.ui

Now, com.ibm.rcp.jfaceex is not included as part of my JRE System Library. It is, however, a bundle that includes classes of its own, as well as the exported packages above.

I was led to beleve that all I needed to do in my own project was to include a reference to it in my own project's build path, but this does not appear to work. The compiler is unable to resolve import statements against the classes in the org.eclipse.swt.widgets package.

If I need those classes, what, exactly do I need to do to import them correctly, and with the least amount of work?

Note We are not using Maven or any third party build tools. This is mandated by management, and I cannot change it.

UPDATE

Per the suggestion of E-Riz, below, I added org.eclipse.swt to the Required Bundles section of the Dependencies tab of my plug-in. Then, I attempt to export the project as follows:

  1. Right click project, select Export.
  2. Select Plug-in Development -> Deployable plug-ins and fragments
  3. Select All, then click Finish

Eclipse builds the project, then tells me there were errors. Examination of the log reveals the following error:

1. ERROR in E:\NotesDev\Plug-in\com.ibm.lotuslabs.ui\src\com\ibm\lotuslabs\ui\UI.java (at line 1)
    /**
    ^
The type org.eclipse.swt.widgets.Shell cannot be resolved. It is indirectly referenced from required .class files

There are dozens of these throughtout my code; one for every reference to a class or method in the org.eclipse.swt namespace bundle. This, despite the fact that the bundle debugs just fine!

UPDATE 2

I've discovered that you can, in fact, put absolute paths into the Bundle-Classpath in MANIFEST.MF. Oddly, this made the compile-time errors vanish. I am not convinced at this point that this is the correct thing to do, since absolute paths are certainly not guaranteed to correspond to the end-user's configuration.

However, installing the plug-in into Notes (the target platform), is not working as intended.

Notes reports that the plug-in installed successfully, but the plugin (an addition to the toolbar) does not appear. I am assuming, at this point, that something with the classpaths still isn't right.

UPDATE 3

Per request, the MANIFEST.MF and build.properties files. Please note that absolute paths were added by Eclipse, through the Dependencies and Runtime tabs.

MANIFEST.MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Context Plug-in
Bundle-SymbolicName: com.ibm.lotuslabs.context.service;singleton:=true
Bundle-Version: 1.0.2
Bundle-Vendor: IBM
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Activator: com.ibm.lotuslabs.context.service.internal.ContextPlugin
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: context.jar,
 lib/activation-1.1.1.jar,
 lib/mail.jar,
 lib/SatuitCRM_XML_API2.jar,
 lib/commons-lang3-3.1/commons-lang3-3.1.jar,
 E:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.eclipse.swt.win32.win32.x86_3.5.2.v3557f-RCP20100710-0200.jar
Require-Bundle: org.eclipse.core.runtime,
 org.eclipse.ui,
 org.eclipse.ui.views,
 org.eclipse.swt,
 com.ibm.rcp.swtex,
 com.ibm.rcp.jfaceex,
 com.satuit.core 
Export-Package: com.ibm.lotuslabs.context.service.document,
 com.ibm.lotuslabs.context.service.internal
Import-Package: org.eclipse.core.resources

build.properties:

output.. = bin/
bin.includes = META-INF/,\
               context.jar,\
               lib/activation-1.1.1.jar,\
               lib/mail.jar,\
               lib/commons-lang3-3.1.jar,\
               lib/SatuitCRM_XML_API2.jar,\
               plugin.xml,\
               E:/NotesDev/Notes/framework/rcp/eclipse/plugins/org.eclipse.swt.win32.win32.x86_3.5.2.v3557f-RCP20100710-0200.jar
jars.compile.order = context.jar
source.context.jar = src/
War es hilfreich?

Lösung

Not quite sure, but two things come to mind.

  • Either remove the jar from your project classpath and add the com.ibm.rcp.jfaceex jar to your target platform (Preferences->PDE->Target platform and point to a directory containing the com.ibm.rcp.jfaceex jar)

  • Or leave the reference and also add the jar to your bundle classpath (on the runtime tab of the MANIFEST)

It don't quite see how this would result in this error, but classpath problems can manifest themselves in weird ways in PDE.

Andere Tipps

Just because a bundle names a package in its Export-Package declaration does not necessarily mean that it contains the code for that package. A bundle can export packages from bundles that it depends on (although I think that's generally a bad idea in most cases).

For you, the solution is simple: in your MANIFEST.MF go to the Dependendencies tab and add org.eclipse.swt to the list of Required Plug-ins

I have taken a look at the swt related bundles in eclipse juno: org.eclipse.swt_3.100.0.v4233d.jar org.eclipse.swt.win32.win32.x86_3.100.0.v4233d.jar

The widgets are in the second bundle which is a fragment to the first.

So you have to make sure both bundles are in the target platform. I am not sure if require bundle works in that case (it may work). You may try to instead import all packages you need. Especially you need Import-Package on the package org.eclipse.swt.widgets.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top