BUG: java.lang.LinkageError When You Refresh URL That Contains an Applet (270860)



The information in this article applies to:

  • Microsoft virtual machine

This article was previously published under Q270860

SYMPTOMS

When you try to refresh a URL that contains an applet, you may receive the following error:
Error loading class: pack1/test/TestApplet
java.lang.LinkageError: Class already defined in the context of this loader: pack1/test/TestApplet
java.lang.ClassNotFoundException: foo/bar/TestApplet
	at com/ms/vm/loader/URLClassLoader.loadClass
	at com/ms/vm/loader/URLClassLoader.loadClass
	at com/ms/applet/AppletPanel.securedClassLoad
	at com/ms/applet/AppletPanel.processSentEvent
	at com/ms/applet/AppletPanel.processSentEvent
	at com/ms/applet/AppletPanel.run
	at java/lang/Thread.run
					
This exception is thrown out of the ClassLoader when you reload the page (either explicitly or by browsing away and coming back), or when you load multiple instances of an applet on the same page.

This problem occurs when you use the Microsoft virtual machine (Microsoft VM) version 33xx.

CAUSE

The problem occurs when the <APPLET=code> tag on the HTML page refers to a packaged class name that is separated by a forward slash (/) instead of a period (.) (for example, pack1/test/TestApplet instead of pack1.test.TestApplet).

RESOLUTION

To work around this problem, use a period to define the packaged class name in your <APPLET=code> tag on the HTML page.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In your favorite editor (for example, Notepad), create a new applet named TestApplet.java, and then paste the following code:
    package pack1.test;
    
    import java.awt.*;
    import java.applet.*;
    import java.util.*;
    
    public class TestApplet extends Applet
    {
        public void init()
        {
            
            setLayout(new BorderLayout());
            add("Center", new Button("It is a Button"));
    		add("North",  new Label("South"));
        }
    }
    					
  2. Save the following HTML file that loads the applet:
    <HTML>
    <HEAD>
    <TITLE>Linkage Error Problem</TITLE>
    </HEAD>
    <BODY>
    <APPLET code=pack1/test/TestApplet
         width=600
         height=500>
    </APPLET> 
    </BODY>
    </HTML>
    					
  3. Use the following command to build the applet:

    jvc /d . TestApplet.java

  4. In Internet Explorer, open the HTML page that you created in step 2. This loads the applet as expected.
  5. Refresh the URL that contains the applet, and the java.lang.LinkageError appears in the Java console.

REFERENCES

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/14/2006
Keywords:kbBug kbFAQ kbpending KB270860