4

I am editing an eclipse plugin code. Just a starter so haven't got much idea about it. Just trying to make it run atm.

The program when run throws ClassNotFoundException. I have included the puakma.jar file to the buildpath of the project and also confirmed that the class exists in the jar file inside SOAP package. What could be the possible problem?

The stacktrace is as follows:

java.lang.NoClassDefFoundError: puakma/SOAP/SOAPFaultException
    at puakma.coreide.ServerManager.createServerConnection(ServerManager.java:120)
    at puakma.vortex.dialogs.server.AppSelectionDialog.listApplications(AppSelectionDialog.java:284)
    at puakma.vortex.dialogs.server.AppSelectionDialog$6.run(AppSelectionDialog.java:234)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.ClassNotFoundException: puakma.SOAP.SOAPFaultException
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 4 more
h-rai
  • 3,636
  • 6
  • 52
  • 76

2 Answers2

3

You need to add correspoinding jar to a Classpath as below for Eclipse plugins:

  1. Open you plugin.xml
  2. Goto Runtime tab
  3. Under classpath section click on "Add" and select the jar file which you have placed in folder under your project (say under lib).
  4. Now clean and build the project

When you do that it will add corresponding entry to MANIFEST.MF as below:

Bundle-ClassPath: lib/foobar.jar,
.

The way you add jars to classpath in eclipse plugins is different from ordinary java projects, since it's based on OSGi.

You can learn more about classpath for eclipse plugins from this link. Hope this helps.

Pradeep Simha
  • 17,683
  • 18
  • 56
  • 107
  • I thought I could right click on the jar files and add them to the build path. Looks like that doesn't work. I followed your approach and it worked fine. Thanx heaps. – h-rai Jun 30 '13 at 11:08
  • 1
    @nick-s You could but the build classpath is not the same thing as runtime classpath. PDE understands that when you add a jar to the OSGi classpath (runtime), you also want it available on the build classpath. – Tom Blodget Jun 30 '13 at 17:38
  • Where is this plugin.xml file stored in windows? @Pradeep Simha – Aman Apr 09 '20 at 14:39
1

More generally, as I have spent hours finding out, in Eclipse there is the Build Path and the Runtime Classpath. The former deals with compiling your java application, and may be accessed in the following manner:

Accessing the Java Build Path

whereas the latter deals with the JRE being able to locate relevant classes at runtime. To set this, you must instead go into the run configurations, go along to the tab marked "Dependencies" and also add your library there. For more information, please search "Eclipse run configuration dependencies"

user7396627
  • 105
  • 2
  • 8