使用Java 7 Update 45,系统属性不再从JNLP标记“属性”设置。 [英] With Java 7 Update 45, the System Properties no Longer Set from JNLP Tag "Property"

查看:147
本文介绍了使用Java 7 Update 45,系统属性不再从JNLP标记“属性”设置。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们从附加的JNLP运行应用程序。在Java控制台上,我们使用D输出系统属性。不再设置JNLP文件中的属性。这是我们遇到此类问题的第一个Java版本。一切都工作正常,包括7 Update 40。

We run the application from the attached JNLP. On the Java console, we have output the system properties with D. The properties from our JNLP files are not set any more. This is the first Java version that we get this sort of problems with. Everything was working fine up to and including 7 Update 40.

我们已经签署了所有的罐子,但是它们的清单中没有安全属性。

We have all the jars signed but there are no security attributes in their manifests.

<?xml version="1.0" encoding="UTF-8"?>

<jnlp spec="1.0+" codebase="http://10.0.10.230/webstart/app" href="desktop.jnlp">
<information>
<title>MyApp Desktop</title>
<vendor>MyApp GmbH</vendor>
<homepage href="http://www.myres-edv.de"/>
<description>MyApp Desktop</description>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.5+" initial-heap-size="512M" max-heap-size="1024M" javaws-vm-args="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8200"/> 
 <property name="org.omg.CORBA.ORBInitialHost" value="10.0.10.230"/>             
 <property name="org.omg.CORBA.ORBServerHost" value="10.0.10.230" />
 <property name="sun.net.spi.nameservice.provider.1" value="dns,sun" />
 <property name="MyApp.baktswritedos" value="true"/>
 <property name="MyApp.nocomm" value="true"/>
 <property name="MyApp.la.erfassungdos" value="true"/>
 <property name="com.sun.corba.ee.transport.ORBTCPConnectTimeouts" value="500:30000:40:30000" />
 <property name="deployment.trace.level" value="all" /> 
 <jar href="myresjar/ejb/myres/myres_ejb_client.jar" main="true" download="eager"/>
 <jar href="myresjar/ejb/myres/myres_ejb.jar" download="eager"/>
 <extension name="jars" href="commonejbjars.jnlp"/>
 <extension name="jars" href="jr.jnlp"/>
 <extension name="jars" href="commonjars.jnlp"/>
 <extension name="jars" href="commonjh.jnlp"/>
 <nativelib href="myresjar/ejb/myres/myres_dll.jar"/>
</resources>
<resources os="Windows">
    <nativelib href="myresjar/myres/native-dlls.jar" download="eager"/>
</resources>
<application-desc main-class="de.myapp.gui.desktop.mainframe.DesktopMainFrame">
   <argument>-serverIP=10.0.0.230</argument> 
   <argument>-initNewDayAction=true</argument> 
</application-desc>
</jnlp>    


推荐答案

我们遇到了与Java 7 Update 45相同的问题( 1.7.0_45)。 JNLP Spec 给出了一个提示解决方法:

We experienced the same Problem with Java 7 Update 45 (1.7.0_45). The JNLP Spec gave a hint for a work-around:


在启动VM之后但在应用程序之前,jnlp文件中设置的属性通常由Java Web Start设置被调用。某些属性被视为安全属性,可以在java调用命令行上作为-Dkey = value参数传递。

Properties set in the jnlp file will normally be set by Java Web Start after the VM is started but before the application is invoked. Some properties are considered "secure" properties and can be passed as -Dkey=value arguments on the java invocation command line.

以下属性以及以...开头的属性javaws。或jnlp。,被认为是安全的,并将以这种方式传递给VM:
...

The following properties, as well as properties beginning with either "javaws." or "jnlp.", are considered "secure" and will be passed to the VM in this way: ...

虽然不安全属性停止工作,但我们意识到仍然可以正确设置安全属性。
也许在VM启动之后但在调用应用程序之前设置属性的机制,已经破坏了这个Java更新,或者这可能是一个有意但未记录的更改。

While "insecure" properties stopped working, we realized that "secure" properties would still be set correctly. Maybe the mechanism that sets properties after the VM is started but before the application is invoked, got broken with this Java update, or maybe this was an intentional but undocumented change.

现在解决方法取决于系统属性的类型:

The work-around now depends on the type of system properties:

对于影响Java行为的系统属性或者我们更改了代码,在应用程序启动时调用 System.setProperty(),而不是在JNLP中设置它们。

For system properties that affect Java behavior or libraries, we changed our code to call System.setProperty() at the application start instead of setting them in the JNLP.

对于属性我们用来配置JNLP文件中的应用程序,我们添加了 jnlp。前缀,以便它们再次正确传递。

For properties that we use to configure the application from the JNLP file, we added the jnlp. prefix so that they are passed correctly again.

<property name="myconfig" value="DE" />

<property name="jnlp.myconfig" value="DE" />

修改:根据 OpenJDK Bug JDK-8023821 ,改变是故意的:

According to OpenJDK Bug JDK-8023821, the change was intentional:


从7u45开始描述符(JNLP文件)开始需要签名才能设置不安全的系统属性。因此预期行为在7u45 ...
(来自评论)

Starting from 7u45 launch descriptor (JNLP file) need to be signed in order to set insecure system properties. So it is expected behaviour in 7u45... (from a comment)

签署JNLP的说明

这篇关于使用Java 7 Update 45,系统属性不再从JNLP标记“属性”设置。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆