简体   繁体   中英

Can't load FXML with webstart

First off my jar file works fine, but every time I try to start the .jnlp I get a runtime exception and this

CacheEntry[file:/C:/Users/Erick/Documents/GitHub/TarotBuddyOnline/out/artifacts/JavaFXApp/JavaFXApp.jnlp]: updateAvailable=true,lastModified=Thu Oct 03 16:41:19 EDT 2013,length=965

I am using the generated .jnlp, even when I start fresh project and try to run the Hello World with FXML, I get the same error.

Before I added

  <security>
  <all-permissions/>
</security>

I was getting this error

CacheEntry[file:/C:/Users/Erick/Documents/GitHub/TarotBuddyOnline/out/artifacts/JavaFXApp/JavaFXApp.jnlp]: updateAvailable=true,lastModified=Thu Oct 03 16:42:16 EDT 2013,length=1014
access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
file:/C:/Users/Erick/Documents/GitHub/TarotBuddyOnline/out/artifacts/JavaFXApp/JavaFXApp.jar!/sample/sample.fxml
  at java.security.AccessControlContext.checkPermission(Unknown Source)
  at java.security.AccessController.checkPermission(Unknown Source)
  at java.lang.SecurityManager.checkPermission(Unknown Source)
  at sun.plugin2.applet.FXAppletSecurityManager.checkPermission(Unknown Source)
  at java.lang.Class.checkMemberAccess(Unknown Source)
  at java.lang.Class.getDeclaredFields(Unknown Source)
  at sun.reflect.misc.FieldUtil.getDeclaredFields(Unknown Source)
  at javafx.fxml.FXMLLoader.getControllerFields(FXMLLoader.java:2543)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2155)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
  at sample.Main.start(Main.java:13)
  at com.sun.javafx.applet.FXApplet2$1.run(FXApplet2.java:132)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
  at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
  at java.lang.Thread.run(Unknown Source)

java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at sun.plugin2.applet.FXAppletSecurityManager.checkPermission(Unknown Source)
    at java.lang.Class.checkMemberAccess(Unknown Source)
    at java.lang.Class.getDeclaredFields(Unknown Source)
    at sun.reflect.misc.FieldUtil.getDeclaredFields(Unknown Source)
    at javafx.fxml.FXMLLoader.getControllerFields(FXMLLoader.java:2543)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2155)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
    at sample.Main.start(Main.java:13)
    at com.sun.javafx.applet.FXApplet2$1.run(FXApplet2.java:132)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
    at java.lang.Thread.run(Unknown Source)
Exception in runnable
java.lang.RuntimeException: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
    at com.sun.javafx.applet.FXApplet2$1.run(FXApplet2.java:148)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
    at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "accessDeclaredMembers")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at sun.plugin2.applet.FXAppletSecurityManager.checkPermission(Unknown Source)
    at java.lang.Class.checkMemberAccess(Unknown Source)
    at java.lang.Class.getDeclaredFields(Unknown Source)
    at sun.reflect.misc.FieldUtil.getDeclaredFields(Unknown Source)
    at javafx.fxml.FXMLLoader.getControllerFields(FXMLLoader.java:2543)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2155)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
    at sample.Main.start(Main.java:13)
    at com.sun.javafx.applet.FXApplet2$1.run(FXApplet2.java:132)
    ... 8 more
CacheEntry[file:/C:/Users/Erick/Documents/GitHub/TarotBuddyOnline/out/artifacts/JavaFXApp/JavaFXApp.jar]: updateAvailable=false,lastModified=Thu Oct 03 16:41:19 EDT 2013,length=18203

Here is the jnlp,

<?xml version="1.0" encoding="utf-8"?>
<jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="JavaFXApp.jnlp">
  <information>
    <title>Sample JavaFX Application</title>
    <vendor>Unknown vendor</vendor>
    <description>Sample JavaFX 2.0 application.</description>
    <offline-allowed/>
  </information>
  <resources>
    <jfx:javafx-runtime version="2.2+" href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
  </resources>
  <resources>
    <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="JavaFXApp.jar" size="18203" download="eager" />
  </resources>

  <applet-desc  width="600" height="400" main-class="com.javafx.main.NoJavaFXFallback"  name="JavaFXApp" >
    <param name="requiredFXVersion" value="2.2+"/>
  </applet-desc>
  <jfx:javafx-desc  width="600" height="400" main-class="sample.Main"  name="JavaFXApp" />
  <update check="background"/>
</jnlp>

I am trying to get this to run on a website btw, What am i doing wrong?

With JavaFX 2.2, you need to sign your app to be able to use FXML in a browser.

The JavaFX 2.2 FXMLLoader internally uses reflection to perform its work - and that won't work in the privileges afforded to an unsigned sandboxed application embedded in a web page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM