• Post Reply Bookmark Topic Watch Topic
  • New Topic

"Bad Magic Number" Loading Applet/Portlet  RSS feed

Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a problem getting an applet to run in a portlet using WSAD 5.0 with the Portal Toolkit and was hoping that someone out there might have a helpful suggestion. There are some platform/environment specific issues but this problem is a real puzzler.
The applet will run by itself and when loaded up into a straight JSP/HTML page. However, it won't run from within a portlet. When loading up the applet I get the following error in the Java Console:
java.lang.ClassFormatError: com/rave/execDashboard/applet/EDBGraphApplet (Bad magic number)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.lang.ClassFormatError: com/rave/execDashboard/applet/EDBGraphApplet (Bad magic number)
Currently, I'm using WSAD 5.0/Portal Toolkit 5.0 with the 1.4.2_02 JRE to compile/run the applet. I've also tried this with 1.3.1_09 with idential results.
Normally a "Bad Magic Number" indicates that the class/jar file is corrupt, however the applet loads/runs fine from within a straight JSP page(WAS 4.0 Test Environment) vs a Portlet/View.JSP(Portal Server 4.2 Test Environment). Another possiblity would require that there be an incompatibility between the JVM used to compile the class vs the one loading/runing it. However, WSAD is using JRE 1.4.2_02 JRE to perform both.
A copy of the <APPLET> tag is below:
(Originally I used the <jsp luging> directive to load the applet but switched back to <APPLET> tags when I discovered that the generated OBJECT,EMBED tags wouldn't work with Netscape 7.1 or Firebird 0.7)
EDBGraphApplet.jar contains my graphing applet and wcis.jar contains an off-the-shelf graphing package I'm extending.
Normally, in a straight-forward JSP I would load up the applet from a directory relative to the JSP. However, in JetSpeed/WebSphere Portal,
"You cannot calculate the codebase relative to the Portlet JSP because this JSP is not accessed directly by the browser.
The codebase must be relative to the jetspeed servlet URI, which is /jetspeed/portal/ by default, thus your codebase should certainly be only "../applets", and this will work wherever your portlet JSPs are located (see: http://www.mail-archive.com/jetspeed-user@jakarta.apache.org/msg09237.html for the original post)"
Anyway, if the loader was unable to find the JAR/Class file I would get either get a FileIO error or a ClassNotFound error.
Does anyone have any suggestions as to what could be causing this problem?
Thanks in advance.
Eagles may soar, but weasels don't get sucked into jet engines.
Posts: 9087
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somewhere on your machine you have two different versions of the jdk. The "bad magic number" means that java is expecting classes from one of them and instead is finding classes from the other version. Get rid of one of the versions and you will have solved your problem.
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it's a JVM version. You would get an UnsuportedClassVersionError. The magic number is the 0xCAFEBABE marker at the beginning of the class files. It would indicate that the class file being loaded is either not a class file or is being corrupted in transit. (perhaps an attempt to transfer a binary file as text file)
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!