尝试运行 Facelets 中嵌入的小程序时出现不兼容的 magic 值 1010792557
当我通过 Glassfish 服务器访问嵌入了小程序的 Facelets 页面时,出现此错误。 虽然当我简单地从计算机上打开它时,它工作正常,所以小程序没问题。 是否可以在 Glassfish(3.1、JSF 2.0)上运行小程序?
这是我尝试的方法:
<applet code="test.TestApplet" archive="TestApplet.jar"/>
I get this error when I access the Facelets page where the applet is embedded, through Glassfish server.
Though when I open it simply from my computer it works fine, so the applet is ok.
Is it possible to run applets on Glassfish (3.1, JSF 2.0)?
Here's how I try:
<applet code="test.TestApplet" archive="TestApplet.jar"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是
ClassFormatError
。有效 Java 类的神奇值为0xCAFEBABE
,即前 4 个字节。但是您得到的是0x3C3F786D
,它代表 ASCII 字符。
因此,对
TestApplet.jar
的请求显然实际上返回了一个 XML 文档。当您将浏览器地址栏中的当前请求 URI 更改为指向TestApplet.jar
文件时(即更改/page.jsf
或/page.xhtml
在/TestApplet.jar
的 URL 末尾)。然后您将看到浏览器尝试下载小程序时实际检索到的内容。也许这是 Facelets 提供的简单 HTTP 404 错误文档。要修复此问题,只需确保
archive
属性中的 URL 正确即可。它与您在浏览器地址栏中看到的当前请求 URL 相关。That's a typical message of a
ClassFormatError
. The magic value of a valid Java class is0xCAFEBABE
, which is the first 4 bytes. But you're getting0x3C3F786D
which stands for the ASCII characters<?xm
.So, the request to
TestApplet.jar
has apparently actually returned a XML document. You should be able to see it yourself when you change the current request URI in browser address bar to point toTestApplet.jar
file (i.e. change/page.jsf
or/page.xhtml
in end of URL to/TestApplet.jar
). Then you'll see what the browser actually retrieved when it tried to download the applet. Perhaps it's a simple HTTP 404 error document served by Facelets.To fix it, just make sure that the URL in the
archive
attribute is correct. It's relative to the current request URL as you see in browser address bar.最后我找到了一个解决方案:
如果我将小程序的 jar 文件放入我的 Web 应用程序的资源文件夹中,并将存档文件的路径设置为如下,
它就可以正常工作。
Finally I found a solution:
If I place the applet's jar file into the resources folder of my web application, and I set the archive file's path to it as the following
it works fine.