java.lang.SecurityException:JAR 清单仅在所有权限下请求 运行
java.lang.SecurityException: JAR manifest requested to run in all-permissons only
我们有一个 Swing 应用程序,它通过 Java Web Start 下载并在本地计算机上运行。但是在自动启动下载的 JNLP 文件后出现错误:
Application Blocked by Security Settings Name: Somename Location:
http://localhost:8080 The Java security settings have prevented this
application from running. You may change this behavior in the Java
Control Panel.
此 URL 已添加到例外站点列表中。
Java 控制台此时不工作,但如果在控制台中通过命令启动此 JNLP 文件:
javaws -verbose filename.jnlp
我们在跟踪中发现了一些异常:
java.lang.SecurityException: JAR manifest requested to run in all-permissons only: http://localhost:8080/path/to/jar/jarname.jar
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.deploy.security.SandboxSecurity.isPermissionGranted(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
at com.sun.javaws.Launcher.prepareResources(Unknown Source)
at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main.access[=13=]0(Unknown Source)
at com.sun.javaws.Main.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
该 Jar 文件的清单:
Manifest-Version: 1.0
version-time: 1926
version-number: 01.030.02.02
Ant-Version: Apache Ant 1.9.4
Application-Name: Somename
Permissions: all-permissions
version-date: March 4 2015
Created-By: 1.7.0_75-b13 (Oracle Corporation)
debug: on
Codebase: *
JNLP 文件的结构:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080/" href="/warname/jnlp/filename.jsp">
<information>
<title>Title</title>
<vendor>Company</vendor>
<homepage href="http://www.foo.com"/>
<description>Description</description>
<offline-allowed/>
</information>
<resources>
<j2se max-heap-size="512m" initial-heap-size="128m"
version="1.3+"/>
<jar href="/warname/jnlp/lib/jarname.jar"/>
<jar href="/warname/jnlp/lib/jarname-2.jar" />
<extension href="/warname/jnlp/help.jsp" name="Java Help"/>
</resources>
<application-desc
main-class="path.to.class.Starter">
<argument>-java.naming.provider.url=someurl</argument>
<argument>-java.naming.factory.initial=someinitial</argument>
<argument>-java.naming.security.principal=login</argument>
<argument>-java.naming.security.credentials=password</argument>
<argument>-locatorConfig=server</argument>
<argument>-verbose</argument>
</application-desc>
</jnlp>
Java 版本:1.7.0_75.
出现该异常的原因是什么?为什么应用程序无法启动?
"all-permissions" 设置意味着应用程序需要访问您的某些系统资源。
在这种情况下,Oracle 表示您必须在 JNLP 和清单文件中定义相同的权限。您应该查看 JNLP 文件的 "security" 元素:
<security>
<all-permissions/>
</security>
您可以找到更多信息here。
您可能需要更改 Java 安全设置。在 Windows 下,您应该在 Java 的控制面板上有一个图标。关于 Linux,您可以 运行 您 JDK.
的 bin 目录中的 "ControlPanel" 应用程序
在 "Security" 选项卡下,您可以添加关于 "localhost" 的例外。这应该可以帮助您解决问题。
我们有一个 Swing 应用程序,它通过 Java Web Start 下载并在本地计算机上运行。但是在自动启动下载的 JNLP 文件后出现错误:
Application Blocked by Security Settings Name: Somename Location: http://localhost:8080 The Java security settings have prevented this application from running. You may change this behavior in the Java Control Panel.
此 URL 已添加到例外站点列表中。
Java 控制台此时不工作,但如果在控制台中通过命令启动此 JNLP 文件:
javaws -verbose filename.jnlp
我们在跟踪中发现了一些异常:
java.lang.SecurityException: JAR manifest requested to run in all-permissons only: http://localhost:8080/path/to/jar/jarname.jar
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.deploy.security.SandboxSecurity.isPermissionGranted(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
at com.sun.javaws.Launcher.prepareResources(Unknown Source)
at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main.access[=13=]0(Unknown Source)
at com.sun.javaws.Main.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
该 Jar 文件的清单:
Manifest-Version: 1.0
version-time: 1926
version-number: 01.030.02.02
Ant-Version: Apache Ant 1.9.4
Application-Name: Somename
Permissions: all-permissions
version-date: March 4 2015
Created-By: 1.7.0_75-b13 (Oracle Corporation)
debug: on
Codebase: *
JNLP 文件的结构:
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://localhost:8080/" href="/warname/jnlp/filename.jsp">
<information>
<title>Title</title>
<vendor>Company</vendor>
<homepage href="http://www.foo.com"/>
<description>Description</description>
<offline-allowed/>
</information>
<resources>
<j2se max-heap-size="512m" initial-heap-size="128m"
version="1.3+"/>
<jar href="/warname/jnlp/lib/jarname.jar"/>
<jar href="/warname/jnlp/lib/jarname-2.jar" />
<extension href="/warname/jnlp/help.jsp" name="Java Help"/>
</resources>
<application-desc
main-class="path.to.class.Starter">
<argument>-java.naming.provider.url=someurl</argument>
<argument>-java.naming.factory.initial=someinitial</argument>
<argument>-java.naming.security.principal=login</argument>
<argument>-java.naming.security.credentials=password</argument>
<argument>-locatorConfig=server</argument>
<argument>-verbose</argument>
</application-desc>
</jnlp>
Java 版本:1.7.0_75.
出现该异常的原因是什么?为什么应用程序无法启动?
"all-permissions" 设置意味着应用程序需要访问您的某些系统资源。
在这种情况下,Oracle 表示您必须在 JNLP 和清单文件中定义相同的权限。您应该查看 JNLP 文件的 "security" 元素:
<security>
<all-permissions/>
</security>
您可以找到更多信息here。
您可能需要更改 Java 安全设置。在 Windows 下,您应该在 Java 的控制面板上有一个图标。关于 Linux,您可以 运行 您 JDK.
的 bin 目录中的 "ControlPanel" 应用程序在 "Security" 选项卡下,您可以添加关于 "localhost" 的例外。这应该可以帮助您解决问题。