This question is a follow-up to this one. Paul Webster graciously helped me to figure out many of my issues, but one nagging issue remains, and I’m fairly certain it comes down to a classpath issue when I’m exporting the plugin, as opposed to when I’m debugging the plugin.
This is the dubious information I’ve figured out so far, by scraping up information from various sources on the Web (for which this page was an invaluable resource):
- Plugins rely entirely on the
Bundle-Classpathin the MANIFEST.MF file. If the class can’t be found in either the JRE System library, the plugin-dependencies, or in a folder or JAR in theBundle-Classpath, aNoClassDefFoundorNoClassFoundexception will occur. - Use
Require-Bundleonly for bundles I’m creating. (In other words, bundles in my workspace. This means, myRequire-Bundlelist is going to be pretty short.) - Use
Import-Packagefor 3rd-party packages that my bundle requires. This list can be fairly large, depending on how many 3rd-party packages I’m using. - If I need a 3rd-party package, and it isn’t exported, I need to create a bundle for it and export that package. Then, in the package that requires it, I need to import the exporting bundle.
- If a bundle itself contains packages inside the bundle and exports them, never put these packages also into the Manifest as imported packages. (In other words, don’t re-export packages that are already exported by a bundle.)
(I’ll update the information above as the community corrects it.)
So, bearing all that in mind, I’ve reworked my MANIFEST.MF file so that it observes the rules above. Everything works beautifully when I debug the application. All classes are found, the plugin runs as expected, but things get ugly when I go to export the plug-in.
When I attempt to export the plugin, all the projects compile except one. The log file contains the following message:
# 7/3/12 10:09:57 AM EDT
# Eclipse Compiler for Java(TM) 0.A76_R36x, 3.6.2, Copyright IBM Corp 2000, 2010. All rights reserved.
----------
1. ERROR in E:\NotesDev\NotesPlugin\com.auth.lotusplugin.popdlg\src\com\auth\lotusplugin\popdlg\SettingsDialog2.java (at line 0)
package com.auth.lotusplugin.popdlg;
^
The type com.ibm.rcp.swt.swidgets.SCoolBar cannot be resolved. It is indirectly referenced from required .class files
----------
1 problem (1 error)
Now, I’ve determined that com.ibm.rcp.swt.swidgets.SCoolBar is exported by com.ibm.rcp.swtex.win32_6.2.2.20100729-1241.jar, which also happens to be exported by com.ibm.rcp.jfaceex_6.2.2.20100729-1241.jar. In my project, I’ve done the following:
- Added
com.ibm.rcp.jfaceexas an additional bundle tobuild.propertiesthrough the Dependencies tab. - Added
com.ibm.rc.swt.swidgetsas an imported package on the Dependencies tab.
Nonetheless, the class cannot be found when I attempt to export the plugin. At this point, I am assuming that there is some fundamental difference between the way a plugin is compiled when it is debugged, versus when it is exported, and that I am unaware of what that difference is.
If someone could please help me to resolve this last issue I’d really appreciate it.
The relevant portions of MANIFEST.MF and build.properties files are included below for reference.
MANIFEST.MF
Require-Bundle: com.ibm.lotuslabs.context.service,
com.ibm.lotuslabs.ui,
com.SatuitCRM.WebServices
Import-Package: com.ibm.rcp.jface.action,
com.ibm.rcp.swt.swidgets,
javax.swing,
lotus.domino,
lotus.notes,
org.eclipse.jface.action,
org.eclipse.jface.window,
org.eclipse.swt,
org.eclipse.swt.events,
org.eclipse.swt.graphics,
org.eclipse.swt.layout,
org.eclipse.swt.widgets,
org.eclipse.ui.plugin,
org.osgi.framework
Export-Package: com.auth.lotusplugin.popdlg;
uses:="com.ibm.rcp.jface.action,
com.ibm.lotuslabs.context.service.document,
com.ibm.lotuslabs.ui,
com.ibm.rcp.jface.action,
com.ibm.rcp.swt.swidgets,
com.satuit.core,
com.SatuitCRM.WebServices,
javax.swing,
lotus.domino,
lotus.notes,
org.eclipse.jface.action,
org.eclipse.jface.window,
org.eclipse.swt,
org.eclipse.swt.events,
org.eclipse.swt.graphics,
org.eclipse.swt.layout,
org.eclipse.swt.widgets,
org.eclipse.ui.plugin,
org.osgi.framework"
Bundle-ClassPath: .,
com.satuit.core.jar,
com.ibm.lotuslabs.ui.jar,
com.ibm.lotuslabs.context.service.jar,
com.SatuitCRM.WebService.jar,
lib/activation-1.1.1.jar,
lib/commons-lang3-3.1.jar,
lib/mail.jar,
lib/SatuitCRM_XML_API2.jar
build.properties
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
plugin.xml,\
lib/commons-lang3-3.1.jar,\
lib/activation-1.1.1.jar,\
lib/mail.jar,\
lib/SatuitCRM_XML_API2.jar,\
.
additional.bundles = com.ibm.rcp.browser.ie,\
com.ibm.rcp.jfaceex
Don’t have a clear cut answer, but maybe these help:
I think that you just need to set up your target platform right. Make sure that your target platform contains all the bundles that you need that isn’t in your workspace. When specifying a dependency, you can use Require-Bundle (or better still Import-Package), regardless if the bundle is in your workspace or in your target platform.
For the rest:
Exporting system packages from your bundle (like javax.swing) is usually a bad idea, as it can mess up the resolution later. You really should only export stuff from a bundle that is in that bundle
I am not too familiar to the ‘additional.bundles’ construction, it’s not standard OSGi, and I don’t think you’ll need it.