PDFRenderer seems not loaded - java.lang.NoClassDefFoundError: com/sun/pdfview/PDFFile

174 views
Skip to first unread message

magn...@gmail.com

unread,
Dec 9, 2015, 12:38:49 PM12/9/15
to qz-print
Hi there,

First, thanks for providing this free software. I'm implementing QZ Print 1.9.4 in my web app. Everything seemed to work 2 weeks ago while I was doing my first "proof of concept" tests. However, now I get an exception during the start of the print request.


Here is the trace I get from the Java console during printing:


network: Cache entry not found [URL : http://127.0.0.1:8080/webapp/print/lib/PDFRenderer-0.9.1.jar, version : null]
cache: Adding MemoryCache entry: http://127.0.0.1:8080/webapp/print/lib/PDFRenderer-0.9.1.jar
cache: Resource http://127.0.0.1:8080/webapp/print/lib/PDFRenderer-0.9.1.jar has expired.
network: Response code for http://127.0.0.1:8080/webapp/print/lib/PDFRenderer-0.9.1.jar : 304
network: Encodage pour http://127.0.0.1:8080/webapp/print/lib/PDFRenderer-0.9.1.jar : null
network: Suspendre la connexion à http://127.0.0.1:8080/webapp/print/lib/PDFRenderer-0.9.1.jar
cache: registerReference: com.sun.deploy.cache.MemoryCache$CachedResourceReference@515ea659: 1
cache: Read manifest for http://127.0.0.1:8080/Customtool-webapp/print/lib/PDFRenderer-0.9.1.jar: read=186 full=12367
cache: Loading full manifest for http://127.0.0.1:8080/Customtool-webapp/print/lib/PDFRenderer-0.9.1.jarcache: registerReference: com.sun.deploy.cache.MemoryCache$CachedResourceReference@515ea659: 2
cache: Clean up the reference queue: http://127.0.0.1:8080/webapp/print/qz-print.jar
cache: deregisterReference: com.sun.deploy.cache.MemoryCache$CachedResourceReference@599e9166: 2
security: blacklist: check contains Qhlx2khFx6gWzC6T7dVrSyicwWoiBBalHoZ6RkIbhO4=, state now IN_MEMORY
security: blacklist: not found in cache
security: Trusted libraries list file not found
cache: Reading Signers from 5793 http://127.0.0.1:8080/webapp/print/lib/PDFRenderer-0.9.1.jar | d:\Profiles\admin\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\54\5578b576-318b2156.idx
cache: Done readSigners(http://127.0.0.1:8080/webapp/print/lib/PDFRenderer-0.9.1.jar)
basic: JNLP2ClassLoader.findClass: com.sun.pdfview.PDFFile: try again ..
déc. 09, 2015 6:22:39 PM qz.PrintRaw clear
INFOS: Print buffer has been cleared.
déc. 09, 2015 6:22:39 PM qz.PrintApplet run
INFOS: ===== JAVASCRIPT LISTENER THREAD STOPPED =====
Exception in thread "Thread-16" java.lang.NoClassDefFoundError: com/sun/pdfview/PDFFile
at qz.PrintPostScript.getPDFFile(Unknown Source)
at qz.PrintPostScript.print(Unknown Source)
at qz.PrintFunction.logAndPrint(Unknown Source)
at qz.PrintFunction.printPS(Unknown Source)
at qz.PrintApplet.startJavaScriptListener(Unknown Source)
at qz.PrintApplet.access$000(Unknown Source)
at qz.PrintApplet$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at qz.PrintApplet.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.sun.pdfview.PDFFile
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
at sun.plugin2.applet.JNLP2ClassLoader.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)
... 10 more

--------------------------------------------------------

The applet is integrated with :
<applet id="qz" archive="qz-print.jar" name="QZ Print Plugin" code="qz.PrintApplet.class" width="55" height="55">
<param name="jnlp_href" value="print/qz-print_jnlp.jnlp" />
<param name="cache_option" value="plugin" />
<param name="disable_logging" value="false" />
<param name="initial_focus" value="false" />
</applet>

In my webapp, I've got a folder "print" containing: QZ Print JAR + JNLP + lib folder (itself containing PDFRenderer).

I've tried referencing PDFRenderer in the JNLP file, but when I got it working the file was not referenced:
<jar href="qz-print.jar" eager="true" download="eager" main="true" />
<!--<jar href="lib/jssc.jar" eager="false" download="lazy" />-->
<!--<jar href="lib/PDFRenderer-0.9.1.jar" eager="false" download="lazy" />-->



Anyone has an idea of what I'm missing please?
I can provide additional details, and I keep working on it. If I get any solution, I'll keep you aware.

Thanks a lot!
Cheers

Tres Finocchiaro

unread,
Dec 9, 2015, 12:43:07 PM12/9/15
to magn...@gmail.com, qz-print
Can you try downloading http://127.0.0.1:8080/webapp/print/lib/PDFRenderer-0.9.1.jar?  Is it accessible?

There's a chance the lib folder has permissions preventing this JAR from being accessed.  Please try in an unauthenticated browser for a proper test.

--
You received this message because you are subscribed to the Google Groups "qz-print" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qz-print+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

magn...@gmail.com

unread,
Dec 10, 2015, 3:45:24 AM12/10/15
to qz-print, magn...@gmail.com
Thanks for your response.
Yes I'm able to download it, even from a non-authenticated session. When typing the direct URL mentioned in the stack trace, the JAR is found and is downloaded right to my "Downloads" folder.

I'm wondering if the JAR is not seem from an executable point-of-view, either because of the JNLP file, or the MANIFEST file.

I tried several configurations for manifest attributes, such as "Trusted-Library: true", "Application-Library-Allowable-Codebase: *"...

Trusted-Library: true
Application-Library-Allowable-Codebase: *
Class-Path: lib/PDFRenderer-0.9.1.jar lib/jssc.jar
Application-Name: QZ Print Plugin
Permissions: all-permissions
Created-By: 1.7.0_76-b13 (Oracle Corporation)
Caller-Allowable-Codebase: *
Main-Class: qz.Main
Codebase: *


NB : Also, I always clear Java + browser caches between my tests.
I'll retry some JNLP/MANIFEST updates.

Cheers

Tres Finocchiaro

unread,
Dec 10, 2015, 10:25:21 AM12/10/15
to magn...@gmail.com, qz-print
How are you signing the JARs before publishing them?

Does the same problem occur on https://demo.qz.io?

If not, you may want to compare what is working on qz.io versus what is not working on your workstation.


Cheers

magn...@gmail.com

unread,
Dec 10, 2015, 3:09:46 PM12/10/15
to qz-print, magn...@gmail.com
Many thanks for this clue! In fact I can print a PDF file using https://demo.qz.io, but I have the same PDFRenderer JAR file issue when using the demo generated from a "ant clean include-assets".

I'm going to proceed by step:
- Either I did too many copy/paste on the JAR file and he got corrupted: I'm gonna test the generated demo without signing the JARs.
- Either it's my JAR signing process or JNLP which is bad. Anyway I'll first try to fix it using the generated demo before embedding the JARs in my webapp.

I sign the 3 JARs (qz-print + PDFRenderer + jssc) with a valid certificate, using the following command:
%JAVA_HOME%\bin\jarsigner.exe -tsa http://timestamp.globalsign.com/scripts/timestamp.dll -storetype PKCS12 -keystore myCertificate.pfx -storepass myStorePwd qz-print.jar "1" -J-Dhttp.proxyHost=myProxyIP -J-Dhttp.proxyPort=8080

The JARs are successfully signed, and that was perfectly working 2 weeks ago. The things which have mainly changed during those 2 weeks are the switches between environments (some backups / re-integrations) and the JNLP/MANIFEST attributes.

Thanks again Tres.

Tres Finocchiaro

unread,
Dec 10, 2015, 4:40:43 PM12/10/15
to magn...@gmail.com, qz-print
If you are building against 1.9.x, I'd recommend trying the private.properties for signing as ant will do it for you.


The private.properties should look something like this:

#1.9 and higher
signing.tsaurl=http://fully.qualified.timestampauthority.url
signing.alias=my-java-signing-alias
signing.keystore=../path/to/keystore.ks
signing.keypass=S3CureP@SSW0RD
signing.storepass=S3CureP@SSW0RD

We've made building easier than ever with 1.9.  https://qz.io/wiki/compiling

FYI, we'll be discontinuing Java Applet support completely in December 2016 when Firefox permanently removes NPAPI.

The new 2.0 branch will become our focus for 2016 and does not have an applet version.

-Tres

magn...@gmail.com

unread,
Dec 11, 2015, 9:38:11 AM12/11/15
to qz-print, magn...@gmail.com
Hi Tres,

To share the information, the problem was coming from manifest "Trusted-Library: true" parameter. My web application is now fixed and working. The JNLP and JAR signing processes were not in cause, they seem to do their jobs.

To supply more details:
- I added a "Trusted-Library: true" attribute in "qz-print.jar" manifest file, in order to remove as many security warnings as possible. The problem is: during printing, "PDFRenderer-0.9.1.jar" is downloaded lazily, but as PDFRenderer manifest file is not a trusted library, these JAR classes were not loaded which explains the NoClassDefFoundError exception.
- To workaround that issue, I also added a "Trusted-Library: true" attribute in "PDFRenderer-0.9.1.jar" manifest file.


So to make a long story shorted:
- "Trusted-Library: true" attribute in "qz-print.jar" manifest file.
- "Trusted-Library: true" attribute in "PDFRenderer-0.9.1.jar" manifest file.
- Signing of both JARs with a valid certificate.
- Customization of manifest.application.allowable.codebase + manifest.caller.allowable.codebase + manifest.codebase with the server domain.
The only security warning left is the certificate one, but that seems acceptable for a web app including an applet.


PS: the branch 2.0 you're talking about -> is this QZ Tray?


Anyway, thanks for your responses and reactivity.
Was really appreciable! Do not hesitate if you want more details.

Cheers
Cédric

Tres Finocchiaro

unread,
Dec 11, 2015, 9:44:31 AM12/11/15
to magn...@gmail.com, qz-print
PS: the branch 2.0 you're talking about -> is this QZ Tray?

Yes, QZ Tray only.

Tres Finocchiaro

unread,
Dec 11, 2015, 9:45:25 AM12/11/15
to magn...@gmail.com, qz-print
> PS: the branch 2.0 you're talking about -> is this QZ Tray?

I mention this specifically because the 1.9 branch builds both QZ Print and QZ Tray.

2.0 removes the QZ Print portions.

magn...@gmail.com

unread,
Dec 11, 2015, 1:43:56 PM12/11/15
to qz-print, magn...@gmail.com
Yep I studied your QZ Tray solution in "socket" package, which seems to be a good replacement for NPAPI obsolescence. Unfortunately the application users don't want to have any third party software installed on their PCs... for now :)

Shortly, I'll probably have to study a replacement for QZ Print as Firefox will remove any support by the end of 2016. I didn't see any news for Internet Explorer, but it seems that Microsoft already broke the line with Edge not implementing NPAPI.

Thanks for your work!

Tres Finocchiaro

unread,
Dec 11, 2015, 2:36:58 PM12/11/15
to magn...@gmail.com, qz-print
Unfortunately the application users don't want to have any third party software installed on their PCs... for now :)

Understood. If they are ok with a "tethered" solution, we just added support for non-localhost printing via https://qz.io/wiki/print-server in our upcoming 1.9.5 release (available now as an release candidate, inquire if interested).

I'll probably have to study a replacement for QZ Print as Firefox will remove any support by the end of 2016. I didn't see any news for Internet Explorer, but it seems that Microsoft already broke the line with Edge not implementing NPAPI.

If you do server-side printing, most languages (php, etc) can do the print queue managing, but from a plugin perspective, it really depends on the printing requirements.  Most printer manufacturers offer a similar solution to ours using some form of WebSocket communication.  From my understanding, some of them install the websocket listeners with the device drivers, so depending on your needs. you may find other solutions out there.

From our feedback with our customers, we're the first to support HTTPS and they tend to prefer our API to the proprietary flavors, but we're interested in knowing which direction you choose.

We even have some selling a white-label of our desktop installer, so some of the the "branded" solutions you see out there may be QZ Tray under the covers. ;)

Thanks for the detailed feedback.

-Tres

Reply all
Reply to author
Forward
0 new messages