java.lang.ClassFormatError: Bad magic number


Web tier: servlets, JSP, Web frameworks: java.lang.ClassFormatError: Bad magic number

  1. java.lang.ClassFormatError: Bad magic number (2 messages)

    I have a jsp which is calling an applet, placed inside a JAR file.

    While loading applet, I am getting this error message.

    Java(TM) Plug-in: Version 1.3.1_01
    Using JRE version 1.3.1_01 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\Ankur

    Proxy Configuration: Manual Configuration


    java.lang.ClassFormatError: SalesCalculatorAppletBeanInfo (Bad magic number)

    at java.lang.ClassLoader.defineClass0(Native Method)

    at java.lang.ClassLoader.defineClass(Unknown Source)

    at Source)

    at sun.applet.AppletClassLoader.findClass(Unknown Source)

    at$201(Unknown Source)

    at$ Source)

    at Method)

    at Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at sun.applet.AppletClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at java.beans.Introspector.instantiate(Unknown Source)

    at java.beans.Introspector.findInformant(Unknown Source)

    at java.beans.Introspector.<init>(Unknown Source)

    at java.beans.Introspector.getBeanInfo(Unknown Source)

    at sun.beans.ole.OleBeanInfo.<init>(Unknown Source)

    at sun.beans.ole.StubInformation.getStub(Unknown Source)

    at sun.plugin.ocx.TypeLibManager$ Source)

    at Method)

    at sun.plugin.ocx.TypeLibManager.getTypeLib(Unknown Source)

    at sun.plugin.ocx.TypeLibManager.getTypeLib(Unknown Source)

    at sun.plugin.ocx.ActiveXAppletViewer.statusNotification(Native Method)

    at sun.plugin.ocx.ActiveXAppletViewer.notifyStatus(Unknown Source)

    at sun.plugin.ocx.ActiveXAppletViewer.showAppletStatus(Unknown Source)

    at Source)

    at Source)

    If any one can help me, then please let me know.

  2. Hi Ankur,
    we got the "Bad magic number" exception mainly if we use SSL and either have a wrong Fingerprint or the SSL implementation does not work.
    Also we had occasions where the Certificate for signing the jar-file is not accepted (for any reasons).
    Perhaps you might check in this direction.

    Jochen Grotepass
  3. Thanks Jochen for ur reply But I got the solution meanwhile.
    One cannot imagine what the reason could be.
    I had this tag in my web.xml file.


    When my applet was loaded, then I dont why but the plug-in is looking for a BeanInfo class(which doesnt exist in my application),
    now when the web server didn't
    find the requested file, it returned a "File Not Found"(404) error, to which applet interpret as 'Bad Magic Number' error.