简体   繁体   中英

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

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 (ie 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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