Finally a subject where I can contribute!  Eclipse has a buddy loading mechanism that solves this issue, and in fact has solved my Class Not Found error.  Yes, I am using RCP.

The Jess plugin is an old style plugin without a MANIFEST.MF but this is easy to fix.  Create a new project based on an existing resource, configure it to be an Eclipse 3.2 plugin, add jess.jar and jsr94.jar from whereever the Jess distribution is (from lib, not from any plugins), and then go to the manifest.mf file.  Here is my version:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Core Plug-in
Bundle-SymbolicName: jess.core
Bundle-Version: 1.0.0
Bundle-ClassPath: .
Bundle-Localization: plugin
Export-Package: javax.rules,
 javax.rules.admin,
 jess,
 jess.awt,
 jess.factory,
 jess.jsr94,
 jess.server,
 jess.speedup,
 jess.swing,
 jess.wizard,
 jess.xml,
 xmlsrc
Eclipse-BuddyPolicy: registered


NOTICE the last line - this registers the plugin to be able to be TOLD about other classes.

Export the plugin to package it up, and then drag a copy of the new plugin to the Eclipse folder.  

Now in my own project, instead of a plugin dependency on the original Jess plugin, I  make my RCP depend on this new plugin, which is called, originally, jess.core. Change the RCP plugin list in the Run configuration so it includes this plugin.

Now when you try to run the application, at least it will start up, but it will still crash with the same class not found error, because we have not completed the buddy registration.  We have only told the system that the new jess.core plugin is registered.  We have to tell our own plugin to register itself as a buddy.  This means that its information, about its classes, will then be available to any plugin listed, that has previously been registered.  Here is the manifest.mf file from my own application:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Glucose Plug-in
Bundle-SymbolicName: edu.utah.cdmcc.decisionsupport.glucose; singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: edu.utah.cdmcc.decisionsupport.glucose.GlucosePlugin
Bundle-Vendor: J. Michael Dean, M.D.
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 org.eclipse.ui.views,
 org.hibernate.eclipse,
 hsqldb.core,
 jess.core
Eclipse-LazyStart: true
Eclipse-RegisterBuddy: org.hibernate.eclipse, jess.core

You see the last line here registers hibernate and jess.  (Hibernate is the reason I ever investigated this problem).

Now save everything, run, and everything works, including the r.add(getPatient()).

It would be useful for the Jess plugins to be fixed - I asked the Hibernate developers to do this, they said they did not understand why, but then they actually fixed their plugin on the next release.  The issue is simply to change the plugins to use manifest.mf and to add that last line to the file, registering the plugin with the line:
 Eclipse-BuddyPolicy: registered

Then anyone using the plugins won't have to do what I did, which is recreate the jess plugin.  This would apply to the other plugins, I think, if someone wanted to use them in an RCP.   (More on that issue in different email).

- Mike

On Jul 18, 2006, at 8:19 AM, friedman_hill ernest j wrote:

I think mdean77 wrote:

shown).   But the patient object already exists and can be accessed  
by getPatient(), so I thought it would be more concise to use r.add 
(getPatient()); 

Not only more concise, but semantically different. Adding a Java
object to working memory is different from constructing a Fact from
the same template.

This failed with a class not found error, so I added the
r.importClass statement.  Nevertheless, I continue to receive a
class not found error.

Ah, OK. Now we're getting somewhere. This is a problem with running
inside an Eclipse plug-in; is that right (or maybe it's an RCP
application?) So you've written a plug-in that uses the Jess plug-in?
Note that the Eclipse platform is just about the most complex
class-loading situation any human is ever likely to face.

Reply via email to