Eclipse plugin giving errors due to NoClassDefFound eventhough class is in the library or Issued fixed Not reflected in the running classes

One of the most annoying problems I face when doing plugin development in eclipse is that the caching problem. You add your eclipse plugin for testing and you find that the plugin is missing some libraries or some class in the plugin contains and issue. So you fix the problem and deploy the plugin again and you get the same problem. And this time you cant even find out what the problem is (and it starts pissing you off greatly). I’m sure every eclipse plugin developer may have faced this atleast once or twice.

The Solution???

Ok without further adue I will tell you why somehting like that can happen. Eclipse has some caching machanism where is caches classes/property files/ manifest etc which was loaded in the eclipse environment.  Unfortunately I coulnd’t find where to remove this cache in eclipse. But some of the cached files can be located in


folder. You can just clear the files in this folder and the caching problem is solved most of the time. (emphasize on the words most of the time). Dont worry about deleting the folders/file which are not relevant to your plugin. Eclipse will cache them again when eclipse starts again. (This is the reason why when run eclipse for the first time it takes a bit more time that when you start eclipse again and again). Anyway it would be easy for you to delete everything since it would not be easy to find the folder relevant to your plugin since the names of the folders are in number rather than your plugin sybolic name.

You can try a new workspace also because if you notice the .metadata folder in the workspace it contains a cached copy of the plugins used.

The very last option you can try is to use a fresh eclipse.🙂

If it still doesn’t work then you better check your plugin again because you haven’t fixed the issue.

Note: I’ve seen this issue both in windows and linux. In windows most of the time clearing the above folder solved my problem, but in linux there were times I had to use a fresh eclipse to find out that there was nothing wrong in my plugin. But have not testing in MAC.

I’m adding this last bit since many plugin developers miss this point and gets the class-def-not found problem. What the user must understand is that the compile time libraries and the runtime libraries for plugins must be defined seperately. The libraries defined for compile time we do in the project properties. They are saved in the “.classpath” file. The libraries for the runtime (i.e. at the time of the plugin is being executed) are specified in the plugin runtime time tab under Classpaths. This is saved in the “MANIFEST.MF” file as Bundle-Classpaths. In the case the plugin does not have a “MANIFEST.MF” the library paths are saved in the “plugin.xml”. Just a fact if somebody still gets noclassdef error nomatter what he/she does.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: