Using Javassist in an Eclipse plugin

I am having problems using javassist when deploying an application as an Eclipse plugin, Concretely, the following code:


is throwing a: javassist.NotFoundException.

The code works fine if not used as part of the plugin. I am trying to understand if the problem is in the configuration of the classpath of my plugin (it does not seem to be the case), or something related to the classloader Eclipse uses when executing a plugin project as an Eclipse Application.

The code that triggers the problem is part of a custom Eclipse editor. So it appears when the user try to open a document associated with the editor. The class javassist is attempting to load is part of the plugin classes.

Thanks in advance for any clue!.


From the documentation of ClassPool:

Returns the default class pool. The returned object is always identical since this method is a singleton factory.

The default class pool searches the system search path, which usually includes the platform library, extension libraries, and the search path specified by the -classpath option or the CLASSPATH environment variable.

The ClassPool returned by ClassPool.getDefault() only adds the system classpath. Eclipse plugins are not loaded by the system classloader so it will not be able to see your plugin's classes.

You need to add your plugin's classloader to the class pool so it can see those classes. This can be done through:

ClassLoader pluginLoader = ...;
ClassPool pool = ClassPool.getDefault();
pool.appendClassPath(new LoaderClassPath(pluginLoader));

where pluginLoader is the classloader of your plugin. The easiest way to get this is probably through

pluginLoader = <one of your plugin's classes>.class.getClassLoader();

Need Your Help

Delegate method not called after dismissing modal view controller

ios objective-c json nsurlrequest nsurlsession

I am using NSURLSessionDataTask to retrieve JSON from a url in my JsonClient class, this class has a delegate protocol to notify when the json task is complete.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.