无法使用webstart加载FXML

时间:2013-10-03 20:55:32

标签: java javafx java-web-start fxml

首先关闭我的jar文件工作正常,但每次我尝试启动.jnlp时都会遇到运行时异常而且这个

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

我正在使用生成的.jnlp,即使我开始新项目并尝试使用FXML运行Hello World,我也会遇到同样的错误。

在我添加之前

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

我收到此错误

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

这是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>

我试图让这个在网站上运行btw,我做错了什么?

1 个答案:

答案 0 :(得分:1)

使用JavaFX 2.2,您需要sign your app才能在浏览器中使用FXML。

JavaFX 2.2 FXMLLoader在内部使用反射来执行其工作 - 并且这不适用于为网页中嵌入的未签名沙盒应用程序提供的权限。