Dienstag, 6. März 2018

ClassNotFoundException in webstart application with multiple extensions - trusted libraries

I've got a webstart application that depends on a third party library that I don't have control over. That library is a giant jar file which contains other third party libraries, among others log4j 1.2.17. In my own main application, I have setup log4j to use a mail appender, so I need to add javax-mail to the classpath. To make things even more difficult, the third party library ships its own jnlp file and resides on a different server than my main application.

I ended up with three jnlp files:
server-a/a.jnlp - refers to my main application jar file
server-b/b.jnlp - refers to the third party jar file
server-a/c.jnlp - refers to javax-mail jar file

All jar files are signed, all jnlp files contain a securty tag (all-permissions). A deployment rule set is setup to allow loading the web application from server-a and server-b without security prompts.

The application loads fine, but when log4j is initialized from within the main class, it throws a ClassNotFoundException for javax/mail/internet/AddressException.

I've tried the following already:

  • upgraded Oracle Java to latest 1.8.x version (currently 1.8.0u161)
    • no change
  • tried with OpenJDK (1.8.0_151-8u151-b12-1~deb9u1-b12)
    • app loads and runs fine
  • replaced the giant third party jar by only a signed version of log4j
    • app loads and runs fine (except I'm missing the functionality from the third party jar)
  • modified and resigned the giant third party jar to not include log4j and provided log4j separately (through a.jnlp or c.jnlp)
    • log4j initializes fine, but the third party code can no longer access log4j

So it seems that something in that giant jar causes the Oracle version of Webstart to deny access from code that lies within that jar to any classes outside of that jar...

My thought: it must be something in the third party jar's manifest file.

Found the following item:
Trusted-Library: true

See: https://docs.oracle.com/javase/8/docs/technotes/guides/deploy/manifest.html#A1148631

Keine Kommentare: