1
votes

When starting a JavaFX Application (with Swing Code embedded) as Webstart the following error occurs:

java.lang.ExceptionInInitializerError
    at com.ookali.reol.annotator.mainApp.MainApp.start(MainApp.java:481)
    at com.sun.javafx.applet.FXApplet2$2.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$174(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(Unknown Source)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$149(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Error when calling sun.swing.JLightweightFrame.getMethod('notifyDisplayChanged').
    at javafx.embed.swing.SwingNode$OptionalMethod.<init>(Unknown Source)
    at javafx.embed.swing.SwingNode.<clinit>(Unknown Source)
    ... 9 more
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessClassInPackage.sun.swing")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPackageAccess(Unknown Source)
    at sun.plugin2.applet.SecurityManagerHelper.checkPackageAccessHelper(Unknown Source)
    at sun.plugin2.applet.FXAppletSecurityManager.checkPackageAccess(Unknown Source)
    at java.lang.Class.checkPackageAccess(Unknown Source)
    at java.lang.Class.checkMemberAccess(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    ... 11 more

the code at MainApp.java:481

final SwingNode sNcontent = new SwingNode();

It is tested in Windows 7 with Java 8 Update 60, Java Security Level "High". All jars of the application are signed with a valid certificate. If the application is started as standalone application it starts without any exceptions.

I tried to set permissions in the jnlp file to all-permissions or j2ee-application-client-permissions but this way java denies to start the application due to security issues. Adding the com.sun packages through rt.jar (from jdk) had no effect on the issue.

Here is the jnlp file used:

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="App.jnlp">
  <information>
    <title>Annotator</title>
    <vendor>Unknown</vendor>
    <description>pdfannotator</description>
    <offline-allowed/>
  </information>
  <resources>
    <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="application.jar" size="656744" download="eager" />
    <jar href="lib/chemistry-opencmis-client-api-0.13.0.jar" size="45801" download="eager" />
    <jar href="lib/chemistry-opencmis-client-bindings-0.13.0.jar" size="372941" download="eager" />
    <jar href="lib/chemistry-opencmis-client-impl-0.13.0.jar" size="168501" download="eager" />
    <jar href="lib/chemistry-opencmis-commons-api-0.13.0.jar" size="154224" download="eager" />
    <jar href="lib/chemistry-opencmis-commons-impl-0.13.0.jar" size="705465" download="eager" />
    <jar href="lib/commons-codec-1.9.jar" size="289895" download="eager" />
    <jar href="lib/commons-io-2.4.jar" size="202638" download="eager" />
    <jar href="lib/commons-logging-1.2.jar" size="70678" download="eager" />
    <jar href="lib/gson-2.2.4.jar" size="211432" download="eager" />
    <jar href="lib/httpclient-4.5.jar" size="782684" download="eager" />
    <jar href="lib/httpcore-4.4.1.jar" size="354806" download="eager" />
    <jar href="lib/jackson-annotations-2.6.0.jar" size="57828" download="eager" />
    <jar href="lib/jackson-core-2.6.0.jar" size="273338" download="eager" />
    <jar href="lib/jackson-databind-2.6.0.jar" size="1218384" download="eager" />
    <jar href="lib/json-20141113.jar" size="73899" download="eager" />
    <jar href="lib/pdfbox-app-1.8.10.jar" size="10968615" download="eager" />
    <jar href="lib/rt-1.5.0_06.jar" size="68040885" download="eager" />
    <jar href="lib/slf4j-api-1.7.5.jar" size="34205" download="eager" />
    <jar href="lib/stax2-api-3.1.4.jar" size="178711" download="eager" />
    <jar href="lib/swing-layout-1.0.3.jar" size="125697" download="eager" />
    <jar href="lib/woodstox-core-asl-4.4.0.jar" size="510465" download="eager" />
  </resources>
  <jfx:javafx-desc  width="600" height="400" main-class="com.ookali.reol.annotator.mainApp.MainApp"  name="annotator" >
  </jfx:javafx-desc>
  <update check="background"/>
</jnlp>
1

1 Answers

0
votes

The problem was the PermissionException "accessClassInPackage.sun.swing" which signifies that in Webstart it is not allowed to use the package sun.swing. Had to remove all usages of classes in package sun.swing in order to get it working.