ICEfaces
  1. ICEfaces
  2. ICE-5633

Full page error responses not handled correctly by our bridge - Cannot call method 'getElementsByTagName' of null

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-Alpha2
    • Fix Version/s: 2.0-Alpha3, 2.0.0
    • Component/s: Bridge, Framework
    • Labels:
      None
    • Environment:
      ICEfaces 2.0

      Description

      If an Ajax request triggers an error on the server and the response is not properly encapsulated as 'error-message' payload but is a full page response like so:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html><head><title>GlassFish v3 - Error report</title><style type="text/css"><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><hr/><p><b>type</b> Exception report</p><p><b>message</b></p><p><b>description</b>The server encountered an internal error () that prevented it from fulfilling this request.</p><p><b>exception</b> <pre>java.lang.NullPointerException</pre></p><p><b>note</b> <u>The full stack traces of the exception and its root causes are available in the GlassFish v3 logs.</u></p><hr/><h3>GlassFish v3</h3></body></html>

      then our bridge will fail with a message something like:

      Uncaught TypeError: Cannot call method 'getElementsByTagName' of null

      The bridge code in question is here:

          if (!namespace.configuration || !namespace.configuration.disableDefaultIndicators) {
      1822 onLoad(window, function() {
      1823 namespace.onServerError(function(code, txtContent, xmlContent) {
      1824 var message = xmlContent.getElementsByTagName("error-message")[0].firstChild.nodeValue;

      // Uncaught TypeError: Cannot call method 'getElementsByTagName' of null
      //occurs in the line above if the response is not a proper Ajax response payload

      1825 var ex = xmlContent.getElementsByTagName("error-name")[0].firstChild.nodeValue;
      1826 PopupIndicator(message, ex, backgroundOverlay);
      1827 });
      1828 namespace.onSessionExpiry(function() {
      1829 PopupIndicator("User session expired", "Reload the page to start another user session", backgroundOverlay);
      1830 });
      1831 });
      1832 }

      We can either try to ensure that errors are always formatted as proper Ajax responses or we can make the bridge more resilient when it gets them.

        Activity

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Deryk Sinotte
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: