Java 我需要做什么才能让 LiveConnect 重新工作?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22156945/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 13:58:14  来源:igfitidea点击:

What do I need to do to get LiveConnect working again?

javanetbeansappletliveconnect

提问by soapergem

Years ago I wrote a Java Web Start application in NetBeans that performs a simple file upload task. For years I had it as a self-signed applet but finally caved and bought a signing certificate. I've got it all signed now, but I'm running into a new problem.

多年前,我在 NetBeans 中编写了一个 Java Web Start 应用程序,它执行一个简单的文件上传任务。多年来,我一直将其作为自签名小程序使用,但最终还是屈服并购买了签名证书。我现在已经全部签署了,但我遇到了一个新问题。

One of the main class' public methods gets called by JavaScript. However, it seems to have stopped working. When I try calling this method manually in Firebug, here's the message I get back:

JavaScript 调用主类的公共方法之一。然而,它似乎已经停止工作。当我尝试在 Firebug 中手动调用此方法时,这是我收到的消息:

Error: Liveconnect call for Applet ID 8 is not allowed in this JVM instance.

UPDATE: Here's the version of the error that I get when I try this in Chrome:

更新:这是我在 Chrome 中尝试此操作时遇到的错误版本:

Error calling method on NPObject.

I am already using the most up-to-date version of the Java plugin (7u51), so what gives? This applet used to work, but now apparently it no longer does. Do I need to add something special to the code? Or change a setting in the way it's compiled by NetBeans?

我已经在使用最新版本的 Java 插件 (7u51),那么有什么用呢?这个小程序曾经可以工作,但现在显然不再有效。我需要在代码中添加一些特殊的东西吗?或者以 NetBeans 编译的方式更改设置?

采纳答案by soapergem

I figured it out; I found some forum posts that mentioned I had to update my Manifest file. Apparently Oracle recently changed the way Liveconnect works so you have to be explicit about allowing subdomains that can call the applet.

我想到了; 我发现一些论坛帖子提到我必须更新我的清单文件。显然,Oracle 最近改变了 Liveconnect 的工作方式,因此您必须明确允许子域可以调用小程序。

The information on that is here, and basically you have to add the Caller-Allowable-Codebasedirective to the Manifest file. Fortunately it can be set to a wildcard, which is what I ended up doing. Apparently you're also supposed to set Application-Namealong with it in the manifest file, and you're specifically NOT supposed to include Trusted-Librarytrue. I don't really know why or what that does, but I was able to adjust my manifest file and everything seems to work again!

相关信息在这里,基本上您必须将Caller-Allowable-Codebase指令添加到清单文件中。幸运的是,它可以设置为通配符,这就是我最终所做的。显然,您还应该Application-Name在清单文件中与它一起设置,并且您特别不应该包含Trusted-Librarytrue。我真的不知道为什么或这样做是什么,但我能够调整我的清单文件,一切似乎又恢复了!