简体   繁体   English

尝试运行Facelets中嵌入的小程序时,魔术值1010792557不兼容

[英]Incompatible magic value 1010792557 when trying to run applet embedded in Facelets

I get this error when I access the Facelets page where the applet is embedded, through Glassfish server. 通过Glassfish服务器访问嵌入小程序的Facelets页面时,出现此错误。 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)? 是否可以在Glassfish(3.1,JSF 2.0)上运行小程序?

Here's how I try: 这是我尝试的方法:

<applet code="test.TestApplet" archive="TestApplet.jar"/>

That's a typical message of a ClassFormatError . 这是ClassFormatError的典型消息。 The magic value of a valid Java class is 0xCAFEBABE , which is the first 4 bytes. 有效的Java类的魔术值是0xCAFEBABE ,这是前4个字节。 But you're getting 0x3C3F786D which stands for the ASCII characters <?xm . 但是您会得到0x3C3F786D ,它表示ASCII字符<?xm

So, the request to TestApplet.jar has apparently actually returned a XML document. 因此,对TestApplet.jar的请求显然已经返回了XML文档。 You should be able to see it yourself when you change the current request URI in browser address bar to point to TestApplet.jar file (ie change /page.jsf or /page.xhtml in end of URL to /TestApplet.jar ). 在浏览器地址栏中将当前请求URI更改为指向TestApplet.jar文件时(即,将URL末尾的/page.jsf/page.xhtml更改为/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. 也许这是Facelets提供的简单HTTP 404错误文档。

To fix it, just make sure that the URL in the archive attribute is correct. 要解决此问题,只需确保archive属性中的URL是正确的。 It's relative to the current request URL as you see in browser address bar. 如您在浏览器地址栏中看到的,它是相对于当前请求URL的。

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 如果我将小程序的jar文件放入Web应用程序的resources文件夹中,并且将归档文件的路径设置为以下内容

<applet code="test.TestApplet" archive="../resources/TestApplet.jar"/>

it works fine. 它工作正常。

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

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