Microsoft KB Archive/270860

= BUG: java.lang.LinkageError When You Refresh URL That Contains an Applet =

Article ID: 270860

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Java 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  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  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.



Steps to Reproduce Behavior
  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(&quot;Center&quot;, new Button(&quot;It is a Button&quot;)); add(&quot;North&quot;, new Label(&quot;South&quot;)); } }                     Save the following HTML file that loads the applet:   Linkage Error Problem</TITLE> </HEAD> <BODY> <APPLET code=pack1/test/TestApplet width=600 height=500> </APPLET> </BODY> </HTML> </li> Use the following command to build the applet:

jvc /d. TestApplet.java

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

<div class="references_section">