jkteater
jkteater

Reputation: 1391

Eclipse - Run Time Error - java.lang.NoClassDefFoundError - Can not get Resolved

Here are the steps that I have completed.

  1. Downloaded PDFRenderer.jar
  2. Created lib folder in my Eclipse Plug-In Project
  3. Copied the jar to the lib folder
  4. Right Click Build Path -> Configure Build Path
  5. Libraries Tab -> Add JARs -> Selected lib/PDFRenderder.jar file

Runtime Tab in MANIFEST.MF

  1. Click Add -> Selected lib/PDFRenderder.jar
  2. Click New -> New Library Name -> entered .
  3. Built the Project - No Errors

Right Click Project

  1. Export -> Deployable plug-ins and fragments -> Pick my plugin project name
  2. Copy exported Project plug-in to my Teamcenter/plug-ins dir

When I run my plug-in project application, and try to access a command using a PDFRenderer command, I get following error.

org.eclipse.core.runtime - org.eclipse.ui - 0 - Unhandled event loop exception java.lang.NoClassDefFoundError: com/sun/pdfview/PDFFile

I know that it is not finding the PDFRenderer Library.
But I am not sure why it is not finding the class?

I am assuming that by adding the PDFRenderder.jar to the plug-in project Referenced library and adding that to the class path. It incorporates the PDFRenderder.jar in to my plug-in project jar file. I don't have to copy PDFRenderder.jar to Teamcenter/plug-ins dir as well?

EDIT

Please see below

Java Build Path

enter image description here

Binary Build

enter image description here

Class Path

enter image description here

Manifest

enter image description here

Project Jar File

enter image description here

Error

enter image description here

Line 287 - PDFFile pdffile = new PDFFile(buf);

Everything seems to be in place to me. But I must be missing something

Upvotes: 2

Views: 4478

Answers (3)

jkteater
jkteater

Reputation: 1391

I could not get the above to work. So I created a plug-in using the external jar file. Added the plug-in the required Plug-ins. Exported the new plug-in jar to my target platform.

This has me up and running.

Upvotes: 0

Pankaj
Pankaj

Reputation: 5250

To solve this issue, you can do one of these.

  1. Make sure that external jar is part of exported jar as explained by Chris.

  2. You can use classpath option to add third party jar which running the class.

Upvotes: 0

Chris Gerken
Chris Gerken

Reputation: 16392

I believe that you have to update the build definition in the plugin.xml editor to specify that the jar dependency be included in the exported jar:

  • Open the plugin.xml file
  • Click on the Build tab
  • Choose the additional files to be included in the builds by checking the boxes next to the filenames
  • Close the plugin.xml editor saving the file.

By default, only classes and resource files in the source folder(s) are included automatically in the build.

Upvotes: 1

Related Questions