本文介绍了Java 7更新45破坏了我的Web Start SWT应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我维护了一个使用WebStart启动的Eclipse RCP应用程序。 Java 7 u45进行了一些安全性更改,现在我的应用程序在启动时崩溃。

I maintain an Eclipse RCP application launched with WebStart. Java 7 u45 made some security changes, and now my application crashes on startup.

我已添加到清单中:

代码库:*

可信任-Library:true

Trusted-Library: true

这删除了控制面板中的所有警告消息。但是在尝试加载我的IApplication实现时,我仍然有一个类加载器问题,可能是我要加载的第一个类。这是更新45的新内容。

This removed all of the warning messages from the Control Panel. But I still have a classloader issue when trying to load my IApplication implemenentation, probably the first of my classes to load. This is new to update 45.

推荐答案

我遇到了同样的问题并通过以下方式设法解决了这个问题:

I have experienced the same issue and managed to solve it by doing following:

在所有清单文件中(对于RCP项目中的每个JAR)添加以下属性:

Application-Name: My App Name
Permissions: all-permissions
Codebase: *
Application-Library-Allowable-Codebase: *
Caller-Allowable-Codebase: *
Trusted-Library: true

解决方案的第二部分是通过添加jnlp前缀来使jnlp属性安全。我找到了解决方案。您需要为框架属性执行此操作(osgi,eclipse ..)和您的属性例如。而不是:

Second part of solution is to make jnlp properties secure by adding jnlp prefix. I have found solution here. You need to do this for framework properties (osgi, eclipse..) and for your properties E.g. instead of:

<property name="eclipse.product" value="com.amdosoft.oct.ui.product"/>
<property name="osgi.instance.area" value="@user.home/Application Data/myApp"/>
<property name="osgi.configuration.area" value="@user.home/Application Data/myApp"/>
<property name="my.App.property" value="someValue"/>

使用

<property name="jnlp.eclipse.product" value="com.amdosoft.oct.ui.product"/>
<property name="jnlp.osgi.instance.area" value="@user.home/Application Data/myApp"/>
<property name="jnlp.osgi.configuration.area" value="@user.home/Application Data/myApp"/>
<property name="jnlp.my.App.property" value="someValue"/>

使用来自

Download eclipse launcher with sources from here

在网络启动启动器中,您需要将属性名称更改为旧值(不含jnlp前缀)。您可以通过将此部分源添加到WebStartLauncher类的main方法中来实现。

In web start launcher you need to change back property names to old values (without jnlp prefix). You can do that by adding this part of source into main method of WebStartLauncher class.

Properties properties = System.getProperties();
// copy properties to avoid ConcurrentModificationException
Properties copiedProperties = new Properties();
copiedProperties.putAll(properties);
Set<Object> keys = copiedProperties.keySet();
for (Object key : keys) {
    if (key instanceof String) {
        String keyString = (String) key;
        if (keyString.startsWith("jnlp.")) {
            // re set all properties starting with the jnlp-prefix
            // and set them without the prefix
            String property = System.getProperty(keyString);
            String replacedKeyString = keyString.replaceFirst("jnlp.", "");

            System.setProperty(replacedKeyString, property);
        }
    }
}

导出新的启动器作为可运行的JAR 并将其放在JNLP文件所在的同一目录中。

Export you new launcher as runnable JAR and put it in the same directory where your JNLP file is located.

编辑JNLP文件添加此项line:

<jar href="myAppLauncher.jar"/>

在标签内部并编辑你的application-desc标签,如下所示:

inside tag and edit your application-desc tag like this:

<application-desc main-class="org.eclipse.equinox.launcher.WebStartMain">
  </application-desc>

这篇关于Java 7更新45破坏了我的Web Start SWT应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 07:34