Frage

I try use applet in my web application.

Applet class:

public class TestApplet extends JApplet {

    @Override
    public void init() {
        try {
            System.out.println("Applet!");
            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    JLabel lbl = new JLabel("Hello World");
                    add(lbl);
                }
            });
        } catch (Exception e) {
            System.err.println("createGUI didn't complete successfully");
        }
    }
}

In JSP:

<applet code="TestApplet.class" width="320" height="120" ></applet>

But when I load page after loading applet, I get this error.

ClassFormatError - Incompatible magic value 168430090 in class file TestApplet.

In my app I use Spring Security - if it's relevant.

War es hilfreich?

Lösung

I've seen this error before when the server sent back an error page or login page instead of the jar/class file. You can use something like fiddler to look at what your webserver is actually sending back to your browser, you should be able to see what it's sending back. A lot of appservers now set httpOnly=true on their cookies, and a bug in the java browser plugin means that it doesn't send the jsessionid when requesting jars. Obviously this only really applies if you're using form-based authentication or similar.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top