Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.ClassFormatError: Incompatible magic value ...

843807Jul 1 2005 — edited Apr 11 2009
I've found a solution to the following error: "java.lang.ClassFormatError: Incompatible magic value ... in class ...".

This problem (at least in my case) appears when the applet tries to get an inexistent remote resource and the server reply with a custom 404 HTML page instead of "HTTP/1.0 404 Not Found" error header. In this case the applet do not recognize the alternative 404 page as valid class and generates the error.

I suggest two alternatives to solve this problem:

1) remove the 404 redirection from server (drastic solution);

2) generate the 404 redirection using a server-side script (JSP, PHP, ASP,...) that analize the HTTP_USER_AGENT environment variable and returns an "HTTP/1.0 404 Not Found" header if contains the "Java" word.
In PHP this script looks like the following:
if ( isset($_SERVER['HTTP_USER_AGENT']) AND (!(strpos($_SERVER['HTTP_USER_AGENT'],"Java")===false))) {
	// returns 404 error because a Java user agent were recognized
	header("HTTP/1.0 404 Not Found");
} else {
	// put here your alternative code ...
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 9 2009
Added on Jul 1 2005
7 comments
1,268 views