I am trying to develop an application which takes a html file or url as input and renders the same as PDF file. I am using yahp for this purpose. I have imported the yahp.jar file, however I am stuck with the following exception:
java.lang.ClassNotFoundException: org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.allcolor.yahp.converter.CClassLoader.findClass(CClassLoader.java:1495)
at org.allcolor.yahp.converter.CClassLoader.findClass(CClassLoader.java:1477)
at org.allcolor.yahp.converter.CClassLoader.loadClass(CClassLoader.java:2056)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.allcolor.yahp.converter.CYaHPConverter.getTransformer(CYaHPConverter.java:383)
at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:246)
at HtmlToPDF.htmlToPdfFile(HtmlToPDF.java:74)
at HtmlToPDF.main(HtmlToPDF.java:52)
SEVERE: Error while getting transformer 'org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer' ! : org.allcolor.yahp.cl.converter.CHtmlToPdfFlyingSaucerTransformer
org.allcolor.yahp.converter.IHtmlToPdfTransformer$CConvertException
at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:255)
at HtmlToPDF.htmlToPdfFile(HtmlToPDF.java:74)Done
at HtmlToPDF.main(HtmlToPDF.java:52)
Caused by: java.lang.NullPointerException
at org.allcolor.yahp.converter.CYaHPConverter.convertToPdf(CYaHPConverter.java:247)
... 2 more
Destroying YAHP ClassLoader Tree
Exception in thread "AWT-Windows" java.lang.IllegalStateException: Shutdown in progress
at java.lang.ApplicationShutdownHooks.add(Unknown Source)
at java.lang.Runtime.addShutdownHook(Unknown Source)
at sun.awt.windows.WToolkit.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
iText “XML Worker” allows developers to convert XML files to PDF documents in a programmer-friendly way. iText can also convert HTML to PDF with the CSS style implemented on HTML elements.
Look at this
Related
I'm trying to make a simple application with Java, using Eclipse that could upload a file from my computer to Dropbox but whenever I compile, I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/conn/params/ConnPerRoute
at javaaplication1.JavaApplication11.main(JavaApplication11.java:32)
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.params.ConnPerRoute
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
Can you help me figure this out?
Thank you in advance.
You miss the httpclient.jar in your classpath. Download it and add it to your classpath.
I am using itext library to know whether the pdf file is protected or not.
i am also add boncycastle library to my class path but it still showing error:
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.asn1.DEREncodable
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
Put this library in your classpath bcprov-jdk15on-1.47.jar
UPDATE
Mind your bouncy castle dependencies version according to the IText version you are using. To double check it with maven repositories. eg. here or here
I'm trying to use the Lizzy library (http://lizzy.sourceforge.net/) to do some playlist manipulation. As a dependency, it requires that I have the Castor library (http://www.castor.org/) in my build path. So I went to the site, and downloaded Castor 1.3.1, then put the .jar into my build path.
However, when I try to run this line of code to convert a specific playlist file to a generic playlist object:
specificPlaylist = SpecificPlaylistFactory.getInstance().readFrom(playlistFile);
I end up getting a NoClassDefFoundError:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/exolab/castor/core/exceptions/CastorException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.exolab.castor.mapping.Mapping.<init>(Mapping.java:81)
at christophedelory.xml.XmlSerializer.getMapping(XmlSerializer.java:100)
at christophedelory.playlist.asx.AsxProvider.readFrom(AsxProvider.java:202)
at christophedelory.playlist.SpecificPlaylistFactory.readFrom(SpecificPlaylistFactory.java:132)
at christophedelory.playlist.SpecificPlaylistFactory.readFrom(SpecificPlaylistFactory.java:168)
...
Am I missing a .jar file? I managed to create an instance of a CastorException class (but it was in a different package than the one the exception is talking about). I thought that the basic Castor-1.3.1.jar file held all of the classes it needed.
Additional information: I'm trying to decode a .wpl playlist file, which should be supported by Lizzy. And my build path looks like this:
Thanks for any help.
You can easily look in the Castor jar to see what's there using a wide variety of tools - WinZip happens to be my tool of choice. You'll find that while there's a CastorException, it's in the wrong package.
Looking at the old downloads page under 1.3.1, I see a Castor-1.3.1-core.jar. Looking in it, I see CastorException in the right package. You may need other jars too - I'd consult the documentation, or continue by trial-and-error, or try to find a POM that will tell you.
Im getting:
load: class wjhk.jupload2/JUploadApplet.class not found.
java.lang.ClassNotFoundException: wjhk.jupload2.JUploadApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://test1/EAMAPP84/data/docuploads/ROADS/NoamTest/wjhk/jupload2/JUploadApplet/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 9 more
Exception: java.lang.ClassNotFoundException: wjhk.jupload2.JUploadApplet.class
on the java consule.
the applet is called:
<applet
code="wjhk.jupload2/JUploadApplet.class"
codebase="\EAMAPP84\data\docuploads\ROADS\NoamTest"
archive="JUpload.jar"
width="650"
height="400">
<param name="actionURL"
value="\\test1\EAMAPP84\data\docuploads\ROADS\NoamTest">
</applet>
while the jar is sitting in the given directory.
the wierd thing is, when i create a simple html file using this it works, butwhen using it in my jsp page i get this error.
anyone?
The code attribute should point to the fully qualified name of the class (the same as you would use in import statement of a normal Java class).
code="wjhk.jupload2.JUploadApplet"
The exception is by the way also hinting that:
java.lang.ClassNotFoundException: wjhk.jupload2.JUploadApplet.class
(the .class part doesn't belong there at all)
and also here:
java.io.IOException: open HTTP connection failed:http://test1/EAMAPP84
/data/docuploads/ROADS/NoamTest/wjhk/jupload2/JUploadApplet/class.class
(note the /class.class part which is obviously wrong)
code="wjhk.jupload2/JUploadApplet.class"
Should probably be..
code="wjhk.jupload2.JUploadApplet"
I have embedded an applet (jar file)in a html page
Now when I am trying to access the web page , it is giving the following error.
<APPLET CODE="com.xxx.tru.ReadNFCSerialNumber" NAME="Read" ID="Read" MAYSCRIPT alt="Photo Id" ARCHIVE="\test.jar, \ojdbc14.signed.jar, \ojdbc14_g.signed.jar" WIDTH="100%" HEIGHT="100%" HSPACE="1" VSPACE="1">
</APPLET>
load: class com.xxx.tru.ReadNFCSerialNumber not found.
java.lang.ClassNotFoundException: com.xxx.tru.ReadNFCSerialNumber
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://localhost/popit/POPit/com/xxx/tru/ReadNFCSerialNumber.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: com.xxx.tru.ReadNFCSerialNumber
What am i doing wrong??
The web browser is trying to load your class from the URI http://localhost/popit/POPit/com/xxx/tru/ReadNFCSerialNumber.class instead of your jar file. The contents of the ARCHIVE attribute looks suspicious to me. Is it really supposed to be a comma-and-space delimited list? Also, the backslashes in front of the file names look suspicious:
ARCHIVE="\test.jar, \ojdbc14.signed.jar, \ojdbc14_g.signed.jar"
I would suggest you look into fixing the ARCHIVE attribute and then see if the web browser will load the class file form the jar as you want it to do.
the CODEBASE attribute is missing. just a thought.code base