简体   繁体   English

Java版本7u45(NPE)之后无法使用Java Web Start

[英]Java web start doesn't work after java version 7u45 (NPE)

Our java application is launchend via java web start (with glassfish 4.0). 我们的Java应用程序是通过Java Web Start(带有glassfish 4.0)启动的。 After updating to java 7u45, it doesn't work anymore. 更新到Java 7u45后,它不再起作用。 Here is the error message: 这是错误消息:

java.lang.NullPointerException
at java.io.StringReader.<init>(Unknown Source)
at org.glassfish.appclient.client.JWSAppClientContainerMain.insertMaskingLoader(JWSAppClientContainerMain.java:186)
at org.glassfish.appclient.client.JWSAppClientContainerMain.main(JWSAppClientContainerMain.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

This happens right after the download finished. 下载完成后立即发生这种情况。 After a quick look into the GF source file, it seems that the property loader.config is not defined as the second line throws the NPE: 快速浏览GF源文件后,似乎未定义属性loader.config因为第二行引发了NPE:

final String loaderConfig = System.getProperty("loader.config");
StringReader sr = new StringReader(loaderConfig);

EDIT The above two code lines where the NPE happens is Glassfish code, from the Class JWSAppClientContainerMain in the jar gf-client-module.jar . EDIT上述其中NPE发生两个代码行是Glassfish的代码,从类JWSAppClientContainerMain在罐子gf-client-module.jar It worked until java update 45. 它一直工作到Java更新45。

As of Update 45, JavaWebstart will no longer pass insecure properties to your application. 从Update 45开始,JavaWebstart将不再将不安全的属性传递给您的应用程序。 All properties that are not prefixed with jnlp or javaws are considered insecure. 没有以jnlpjavaws为前缀的所有属性均被视为不安全。

You either need to change loader.config to jnlp.loader.config (both in the JNLP as well as your java code), or you need to sign the JNLP (place an exact copy of your JNLP in JNLP-INF/APPLICATION.JNLP inside your jar and sign the jar). 您或者需要将loader.config更改为jnlp.loader.config (在JNLP和Java代码中),或者需要对JNLP进行签名(将JNLP的确切副本放置在JNLP-INF/APPLICATION.JNLP在罐子里并在罐子上签名)。

According to this OpenJDK Bugreport this is an intentional change to resolve a security vulnerability 根据此OpenJDK Bugreport,这是有意更改,以解决安全漏洞

There is no property with key "loader.config" in your system properties.that's why it returns null value to loaderConfig . 您的系统属性中没有键为“ loader.config”的属性。这就是为什么它向loaderConfig返回空值的原因。 When you pass null value to the StringReader constructor, it will throw NPE since the length method is invoked on the input Constructor argument ( null value). 当您将null值传递给StringReader构造函数时,由于将在输入的Constructor参数( null值)上调用length方法,因此它将抛出NPE。 Please see below 请看下面

public StringReader(String s) {
        this.str = s;
        this.length = s.length();
    }

Hope this helps 希望这可以帮助

We searched a lot about this issue and luckily we found a solution that worked perfectly for us. 我们对此问题进行了很多搜索,幸运的是,我们找到了一个非常适合我们的解决方案。

in our jnlp file we had: 在我们的jnlp文件中,我们有:

<resources>
        <j2se version="1.5+"/>
        ...
</resources>

we have changed it in this mode: 我们已在此模式下进行了更改:

<resources>
        <j2se version="1.6+" java-vm-args="-Djava.net.preferIPv4Stack=true"/>
        ...
</resources>

we found this solution here: 我们在这里找到了这个解决方案:

https://community.oracle.com/thread/2520987 https://community.oracle.com/thread/2520987

Hope this may help you. 希望这对您有帮助。

glassfish 4.1中解决了此问题,然后将Java降级到u21或更早的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM