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

青春壹個敷衍的年華 提交于 2019-12-13 20:06:06

问题


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"/>

回答1:


That's a typical message of a ClassFormatError. The magic value of a valid Java class is 0xCAFEBABE, which is the first 4 bytes. But you're getting 0x3C3F786D 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 to TestApplet.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.




回答2:


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

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

it works fine.



来源:https://stackoverflow.com/questions/8030528/incompatible-magic-value-1010792557-when-trying-to-run-applet-embedded-in-facele

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!