Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4948594

Runtime error (Object doesn't support this property or method) (liveconnect)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • deploy
    • x86
    • windows_xp



      Name: gm110360 Date: 11/04/2003


      FULL PRODUCT VERSION :
      C:\>java -version
      java version "1.4.1_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
      Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)

      FULL OS VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      problem is demonstrated using extremelly simple applet-javascript-html sample

      when an Applet1 writes dynamically an Applet2 (via insertAdjacentHTML and Liveconnect call (window.eval)) and a javascript method is invoked to a public
      method of an Applet2 (document.applets["Applet2"].foobar()) a run time
      exception is reported Object doesn't support this property or methodthod
      indicating that the public method of the dynamically written Applet2 CAN NOT
      BE FOUND

      The same samples running Microsoft JVM (Microsoft (R) VM for Java, 5.0 Release 5.0.0.3810) work fine, no run time errors and liveconnect works as expected

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. enable SUN JVM -plugin
      2. open Page1.htm in the browser (i.e http://127.0.0.1/SUNJVM/Page1.htm)
      3. you should see two gray boxes and a button (2 applets)
      4. click on the button labeled "call foobar (public method in the Applet2)"
      (button calls javascript function foobar() which then calls Applet2
      public method public String foobar()
      at this point RunTime exception occurs (Object doesn't support this property or method)


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      after clicking button labeled "call foobar (public method in the Applet2)"
      javascript alert should display "Applet 2 foobar called and returned this string value!" (wihtout Runtime error!)
      ACTUAL -
      after clicking button labeled "call foobar (public method in the Applet2)"
      RunTime exception occurs (Object doesn't support this property or method)


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.NullPointerException
      at sun.plugin.viewer.context.IExplorerAppletContext.getJSObject(IExplorerAppletContext.java:132)
      at sun.plugin.AppletViewer.getDocumentBase(AppletViewer.java:957)
      at sun.plugin.AppletViewer.getCodeBase(AppletViewer.java:1019)
      at sun.plugin.AppletViewer.appletInit(AppletViewer.java:548)
      at sun.plugin.viewer.LifeCycleManager.initAppletPanel(LifeCycleManager.java:171)
      at sun.plugin.viewer.IExplorerPluginObject$Initer.run(IExplorerPluginObject.java:169)



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      1. source code for Applet1:

      import netscape.javascript.*;

      public class Applet1 extends Applet {
      public void init() {
      }
      public void start() {
      StringBuffer html = new StringBuffer();
      html.append("window.document.body.insertAdjacentHTML('afterBegin','");
      html.append("<span id=\"uSpnd\" style=\"visibility:visible; position:absolute; top:0px; left:0px; width:100%; height:100%;\"></span>');");
      html.append("uSpnd.insertAdjacentHTML('afterBegin','");
      html.append("<HTML>");
      html.append("<HEAD>");
      html.append("</HEAD>");
      html.append("<BODY>");
      html.append("<applet code=Applet2.class name=Applet2 width=320 height=200></applet>");
      html.append("</BODY>");
      html.append("</HTML>");
      html.append("');");
      try {
      JSObject window = JSObject.getWindow(this);
      window.eval(html.toString());
      } catch (Exception e) {
      System.out.println(e.getMessage() + "exception eveluating js: " + html.toString());
      }

      }
      }

      2. Source code for Applet2

      import java.applet.*;

      public class Applet2 extends Applet {
      public void init() {
      }

      public String foobar() {
      return "Applet 2 foobar called and returned this string value!";
      }
      }

      3. Source code for Page1.htm

      <HTML>
      <HEAD>
      </HEAD>
      <BODY>
      <CENTER>
      <applet code=Applet1.class name=Applet1 width=320 height=200 MAYSCRIPT></applet>
      <script>
      function foobar() {
      alert(document.applets["Applet2"].foobar());
      }
      </script>
      <FORM><INPUT TYPE="button" NAME="test" VALUE="call foobar (public method in the Applet2)" onClick="foobar()"></FORM>
      </CENTER>
      </BODY>
      </HTML>
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      none!

      need to be able to call public Applet methods via javascript from Applets
      written dynamically in the page (using insertAdjacentHTML DHTML API)
      (Incident Review ID: 193790)
      ======================================================================

            djayaramsunw Devananda Jayaraman (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: