Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassNotFoundException even though the class is included in a jar file included in the buildpath

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
like image 323
h-rai Avatar asked Oct 22 '25 17:10

h-rai


1 Answers

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.

like image 131
Pradeep Simha Avatar answered Oct 24 '25 06:10

Pradeep Simha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!