java.lang.ClassFormatError: Bad magic number

Discussions

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

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

    Hi,
     
    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

    Proxy: 192.168.11.6:80

    java.lang.ClassFormatError: SalesCalculatorAppletBeanInfo (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 sun.plugin.security.PluginClassLoader.access$201(Unknown Source)

    at sun.plugin.security.PluginClassLoader$1.run(Unknown Source)

    at java.security.AccessController.doPrivileged(Native Method)

    at sun.plugin.security.PluginClassLoader.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 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$1.run(Unknown Source)

    at java.security.AccessController.doPrivileged(Native 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 sun.applet.AppletPanel.run(Unknown Source)

    at java.lang.Thread.run(Unknown Source)



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

    Regards,
    Ankur
  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
    http://galaxy.sagadc.com
    http://www.sagadc.com
  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.

    <error-page>
        <error-code>404</error-code>
        <location>/SCLogin.jsp</location>
    </error-page>

    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.