java - 在 Java 7 Update 45 中,不再从 JNLP 标记 "Property"设置系统属性

标签 java properties system java-web-start jnlp

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

我们已对所有 jar 进行了签名,但它们的 list 中没有安全属性。

<?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给出了解决方法的提示:

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.

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 更新破坏了,或者这可能是一个有意但未记录的更改。

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

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

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

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

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

编辑: 根据 OpenJDK Bug JDK-8023821 ,更改是故意的:

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)

Instructions for signing a JNLP .

关于java - 在 Java 7 Update 45 中,不再从 JNLP 标记 "Property"设置系统属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19400725/

相关文章:

java - JTable 单元格内的 JDateChooser Enter 键并不总是有效

php - C 程序中的 block 系统命令

java - 在Java中复制目录

java - 尝试将 js 数组映射到 List<CustomClass> 时出现错误请求,Spring MVC

java - 我可以在开发后期实现 JBullet 物理吗

c# - 设计时 Form 的自定义可浏览属性

iphone - iOS - 我可以修改 iPhone 中的实时属性列表文件吗?

objective-c - 在 Objective C 中使用点表示法有哪些要求?

c - 在 64 位系统上,如何将 int 作为 void * 传递

Android - 根用户 - 挂载 : Read-only file system