Error when use iText and PdfBox Libraries

Hi Guys,
I’m trying to make some pdf reports from model elements in my plugin.
When i import any class from these two libraries(Itext or PdfBox),my plugin stop working and don’t process any more.
I’m using vp 15.0 enterprise edition , eclipse Oxygen (4.7.0) with jdk 1.8.0.
Libraries used: itextpdf-5.5.13.jar and pdfbox-2.0.12.jar
(also added both jar libraries into project build path)
I test my codes outside of vp and every thing was ok but when i run the class inside vp it does not work.

Here is the log file generated by vp when i use following line at top of my class :

Lines caused the error:

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.font.PDType1Font;

Log file:

[2018/11/18 16:01:44] [message] Exception in thread “AWT-EventQueue-0”
[2018/11/18 16:01:44] [message] java.lang.NoClassDefFoundError: org/apache/pdfbox/pdmodel/font/PDFont
[2018/11/18 16:01:44] [message] at packageGUI.ChooseDetails$3.actionPerformed(ChooseDetails.java:194)
[2018/11/18 16:01:44] [message] at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
[2018/11/18 16:01:44] [message] at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
[2018/11/18 16:01:44] [message] at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
[2018/11/18 16:01:44] [message] at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
[2018/11/18 16:01:44] [message] at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.Component.processMouseEvent(Unknown Source)
[2018/11/18 16:01:44] [message] at javax.swing.JComponent.processMouseEvent(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.Component.processEvent(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.Container.processEvent(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.Component.dispatchEventImpl(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.Container.dispatchEventImpl(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.Component.dispatchEvent(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.Container.dispatchEventImpl(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.Window.dispatchEventImpl(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.Component.dispatchEvent(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.EventQueue.access$500(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.EventQueue$3.run(Unknown Source)
[2018/11/18 16:01:44] [message] at java.awt.EventQueue$3.run(Unknown Source)
[2018/11/18 16:01:44] [message] at java.security.AccessController.doPrivileged(Native Method)
[2018/11/18 16:01:44] [message] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
[2018/11/18 16:01:45] [message] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
[2018/11/18 16:01:45] [message] at java.awt.EventQueue$4.run(Unknown Source)
[2018/11/18 16:01:45] [message] at java.awt.EventQueue$4.run(Unknown Source)
[2018/11/18 16:01:45] [message] at java.security.AccessController.doPrivileged(Native Method)
[2018/11/18 16:01:45] [message] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
[2018/11/18 16:01:45] [message] at java.awt.EventQueue.dispatchEvent(Unknown Source)
[2018/11/18 16:01:45] [message] at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
[2018/11/18 16:01:45] [message] at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
[2018/11/18 16:01:45] [message] at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
[2018/11/18 16:01:45] [message] at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
[2018/11/18 16:01:45] [message] at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
[2018/11/18 16:01:45] [message] at java.awt.EventDispatchThread.run(Unknown Source)
[2018/11/18 16:01:45] [message] Caused by: java.lang.ClassNotFoundException: org.apache.pdfbox.pdmodel.font.PDFont
[2018/11/18 16:01:45] [message] at java.net.URLClassLoader.findClass(Unknown Source)
[2018/11/18 16:01:45] [message] at java.lang.ClassLoader.loadClass(Unknown Source)
[2018/11/18 16:01:45] [message] at v.bdi.h.loadClass(:37)
[2018/11/18 16:01:45] [message] at java.lang.ClassLoader.loadClass(Unknown Source)

Hi, do you specify those 2 jars into VP’s plugin.xml
Specify the <library>(s) in <runtime> tag.

Example:

<plugin ...> 
	<runtime>
		<library path="lib/sampleplugin.jar" relativePath="true"/>
	</runtime>
</plugin>
1 Like

You are right, i must copied the jar library into my plugin -> lib folder and also added the above block into plugin.xml file.
Thank you so much for your help :pray::pray::raised_hands: