更新到 JRE 7u21 后 Java 小程序停止工作 [英] Java applet stopped working after update to JRE 7u21

查看:23
本文介绍了更新到 JRE 7u21 后 Java 小程序停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 JRE 更新到 7u21 后,我的 Java 小程序停止工作.

My java applet stopped working once JRE was updated to 7u21.

简短摘要:

  • 我得到的异常是:netscape.javascript.JSException 和
    java.lang.NoClassDefFoundError.小程序运行良好,直到 JRE7u21.

  • The Exceptions I get are: netscape.javascript.JSException and
    java.lang.NoClassDefFoundError. the applet worked fine until JRE 7u21.

小程序使用 Oracle 的 DeployJava.js 嵌入到网页中.

The applet is embedded in a web page using Oracle's DeployJava.js.

小程序已签名,它使用 LiveConnect 来触发事件,它通过 JNI 访问 USB 和串行端口,它使用来自多个 JAR 文件的代码.

The applet is signed, it uses LiveConnect to fire events, it access USB and serial ports through JNI, it uses code from multiple JAR files.

失败发生在所有经过测试的桌面浏览器(Firefox、chrome、IE8/9 和 Mac 上的 Safari)上.

The failure happens on all desktop browsers tested (Firefox, chrome, IE8/9 and Safari on Mac).

详情:

  • 我有一个 Java 小程序,它允许我的网站与 USB 设备进行通信.

  • I have a java applet that allows my website to communicate with a USB device.

该小程序在过去一年中运行良好.

The applet has been working well for the past year.

JRE7 更新 21 发布后 - 小程序停止工作.

Once JRE7 update 21 was released - the applet stopped working.

小程序托管在使用 Oracle 的 DeployJava.js 库的网页 (ASP.NET) 中.

The applet is hosted in a web page (ASP.NET) using Oracle's DeployJava.js library.

它使用 LiveConnect 将事件引发回我的 javascript 代码.

It uses LiveConnect to raise events back to my javascript code.

我在 JRE 7u21 上遇到的第一个问题是第一次尝试通过 LiveConnect 引发事件时出现异常:

The first problem I had on JRE 7u21 was an exception on the first attempt to raise an event through LiveConnect:

netscape.javascript.JSException: JavaScript error while calling "_notify"
at sun.plugin2.main.client.MessagePassingJSObject.newJSException(Unknown Source)
at sun.plugin2.main.client.MessagePassingJSObject.waitForReply(Unknown Source)
at sun.plugin2.main.client.MessagePassingJSObject.call(Unknown Source)
at <myapplet>.fireJavascriptEvent(Unknown Source)
at <myapplet>$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.asec.easypark.applets.HomeloadingApplet.start(Unknown Source)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.start(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

为了缓解这个问题,我在小程序的 ant 脚本的清单"部分添加了以下行:

in order to mitigate this problem I added the following line to 'manifest' section in the ant script for the applet:

attribute name="Trusted-Library" value="true" 

我使用 JDK 7u21 构建了小程序,它似乎有帮助:

I built the applet using JDK 7u21 and it seemed to help:

之后我又开始收到另一个错误——所以我相信这个问题已经解决了,但它可能导致了下一个问题.

after that I started getting another error - so I believe this one was solved, but it may have caused the next problem.

第二个问题是:小程序正在从几个 JAR 文件调用代码.在第一次调用另一个 JAR 文件(不是小程序的)中的代码时失败,出现以下异常:

the second problem is this: the applet is calling code from several JAR files. on the first call to code in another JAR file (not that of the applet) fails with the following exception:

**java.lang.NoClassDefFoundError**: com/codeminders/hidapi/HIDManager
    at <PackageInSecondJar>.communication.HIDTransmitter.open(Unknown Source)
    at <PackageInSecondJar>.communication.HIDTransmitterSearcher.find(Unknown Source)
    at <PackageInSecondJar>.communication.CompositeTransmitterSearcher.find(Unknown Source)
    at <PackageInAppletJar>.communication.AppletCommunicationBroker.setupDeviceProxy(Unknown Source)
    at <PackageInAppletJar>.communication.AppletCommunicationBroker.setup(Unknown Source)
    at <PackageInAppletJar>.<TheApplet>$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at <PackageInAppletJar>.<TheApplet>.start(Unknown Source)
    at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.start(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

我已经尝试了以下措施 - 没有成功:

I already tried the following measures - without success:

  • 添加 HTTP 标头 'Cache-Control' = 'no-cache'

  • add HTTP header 'Cache-Control' = 'no-cache'

添加 HTTP 标头 'Cache-Control' = 'no-cache, no-store, must-revalidate'

add HTTP header 'Cache-Control' = 'no-cache, no-store, must-revalidate'

使用来自 http://java.com/js/deployJava.txt 的最新 DeployJava.js(重命名为 .js 后)

use latest DeployJava.js from http://java.com/js/deployJava.txt (after renaming to .js)

小程序已经具备以下功能:

The applet already has these features:

  • 在 jnlp 中标记安全性all-permissions"

  • mark security ‘all-permissions’ in jnlp

主 JAR 使用来自外部 CA 的证书签名

the main JAR is signed with certificate from an external CA

小程序代码在 AccessController.doPrivileged 块中运行.

the applet code is running inside a AccessController.doPrivileged block.

我是 Java 新手,所以请不要忽视明显的解决方案...

I'm a java newbie so please don't disregard the obvious solutions...

预先感谢您的帮助,

伙计.

推荐答案

无法将小程序的属性设置为在 7.0.21 及更低版本上都可以使用.

It's not possible to set the attributes of an applet to work both on versions after 7.0.21 and below it.

Trusted-Library: true

属性适用于 7.0.21 以下的那些,这会导致在 7.0.21 之后显示安全对话框(并且很可能您的代码被阻止).如果你只放

attribute works for the ones below 7.0.21 which causes a security dialog to be displayed (and most probably your code to be blocked) after 7.0.21. If you only put

Caller-Allowable-Codebase: *.yourdomain.com

对于您的清单文件,它在 7.0.21 之后的版本开始正常工作,但这次它在 7.0.21 以下的版本中停止.这是一个巨大的混乱.

to your manifest file, it starts to work fine with the versions after 7.0.21 but this time it stops with the versions below 7.0.21. This is a huge mess.

然而,他们已经在最新版本 (7.0.51) 中修复了这种不良行为.所以我建议同时使用适用于 Java 6 和 7.0.51 的两个属性(Trusted-LibraryCaller-Allowable-Codebase).我认为 7.0.21 和 7.0.45 之间没有解决方案.(我不支持他们,我们要求我们的客户升级到 7.0.51).

However they've fixed this ill behaviour with the latest version (7.0.51). So I suggest to use both attributes (Trusted-Library and Caller-Allowable-Codebase) which will work for Java 6 and 7.0.51. I don't think there is a solution for the ones between 7.0.21 and 7.0.45. (I do not support them, we ask our clients to upgrade to 7.0.51).

https://blogs.oracle.com/java-platform-group/entry/7u45_caller_allowable_codebase_and

这篇关于更新到 JRE 7u21 后 Java 小程序停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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