gpt4 book ai didi

JavaFX SwingNode ExceptionInInitializerError

转载 作者:太空宇宙 更新时间:2023-11-04 13:22:30 25 4
gpt4 key购买 nike

当启动 JavaFX 应用程序(嵌入了 Swing 代码)作为 Webstart 时,会发生以下错误:

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

MainApp.java:481 处的代码

final SwingNode sNcontent = new SwingNode();

它在 Windows 7 中使用 Java 8 Update 60、Java 安全级别“高”进行了测试。应用程序的所有 jar 都使用有效证书进行签名。如果应用程序作为独立应用程序启动,它将毫无异常(exception)地启动。

我尝试将 jnlp 文件中的权限设置为 all-permissions 或 j2ee-application-client-permissions,但这样 java 由于安全问题而拒绝启动应用程序。通过 rt.jar(来自 jdk)添加 com.sun 包对问题没有任何影响。

这是使用的 jnlp 文件:

<?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>

最佳答案

问题是 PermissionException“accessClassInPackage.sun.swing”,这表示在 Webstart 中不允许使用包 sun.swing。必须删除 sun.swing 包中类的所有用法才能使其正常工作。

关于JavaFX SwingNode ExceptionInInitializerError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32951653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com