Jack Straub
Jack Straub

Reputation: 470

Launching a program via JNLP produces security exception

If I read the JavaFX deployment guide correctly, I should be able to deploy an unsigned application so long as "the application requires [no] elevated privileges... ." I have reduced my application to the following bit of code:

package fxadhoc;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class FXAdHoc
    extends Application
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        System.out.println( "launch" );
        launch( args );
    }

    @Override
    public void start(Stage stage) throws Exception
    {
        Pane    root    = new Pane();
        root.getChildren().add( new Label( "Testing" ) );
        Scene   scene  = new Scene( root );
        stage.setScene( scene );
        stage.show();
    }
}

When I double-click the jar file (created by NetBeans) nothing happens. When I try to launch via the html or jnlp files (also created by NetBeans) I get a security exception:

Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "javafx.debug" "read")

The full stack trace is provided below.

I am running Windows 7 with all the latest updates applied. I have downloaded the most recent version of NetBeans (7.1.1) which comes equipped with the latest version of JavaFX. I have downloaded the JavaFX samples, and they run fine. (In case you're curious, I tried self-signing the application and got the exception "ava.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\jack\Documents\NetBeansProjects\FXAdHoc\dist\bin\mat.dll"). I get the same exceptions when I build on Linux (again using NetBeans 7.1.1).

Can anyone tell me what I'm missing? Thanks...

The full stack trace for the exception:

java.lang.RuntimeException: Application launch error
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:104)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:140)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:27)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:97)
    ... 1 more
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "javafx.debug" "read")
    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.checkPropertyAccess(Unknown Source)
    at java.lang.System.getProperty(Unknown Source)
    at com.sun.javafx.runtime.SystemProperties.getProperty(SystemProperties.java:178)
    at com.sun.javafx.runtime.SystemProperties$1.run(SystemProperties.java:67)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.runtime.SystemProperties.<clinit>(SystemProperties.java:62)
    ... 4 more

Upvotes: 1

Views: 1603

Answers (1)

Jack Straub
Jack Straub

Reputation: 470

Apparently I had three different problems; please correct me if I get any of this wrong.

  1. It should be possible to deploy an unsigned jar file, but you can't. I believe this is a known issue.
  2. Downloading and installing the JavaFX runtime doesn't automatically make it available from the path. (I don't know why I can run the samples when I can't run my own code, but I'll have to figure that out.) Putting "...\JavaFX 2.o runtime\bin" in my path cured my "mat.dll not found" problem. Presumably getting the directory containing libmat.so into the path on my Linux system will cure the problem there, too.
  3. As I tried different approaches to fixing the problem, I was also occasionally getting an "unsigned resource" exception, even when my jar file was signed. I believe this is a known Java issue going back to at least 1.4. The solution was to disable caching temporary files (Windows control panel/java/general/settings). Note that some remarks I read said that enabling caching is what fixes the problem.

Upvotes: 1

Related Questions