Menu

#798 regression from 1.14 to 2.x - "Automation server" exception

2.4
closed
None
5
2015-01-19
2009-03-20
JP
No

Unfortunately this bug report won't be as good as it could be because the server side of the equation is behind the firewall of one of my clients and my access to that system is very limited. That said, here is everything I know...

I have a Java-based desktop application that uses htmlunit for HTTP-based authentication to another product with a web interface. Using htmlunit 1.14 and its associated third party libs, this authentication sequence worked fine. After upgrading htmlunit and its dependencies first to version 2.3 and later to version 2.4, this authentication sequence is now broken. It is breaking with the following stack trace:

Caused by: com.gargoylesoftware.htmlunit.ScriptException: Wrapped java.lang.Exception: Automation server can't create object (script in http://cgportcl1/portal/site/cooley/template.DM/ from (145, 62) to (273, 18)#200)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:513)
at org.mozilla.javascript.Context.call(Context.java:515)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:444)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:961)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:152)
at com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:165)
at com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:586)
at com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:916)
at org.mozilla.javascript.Context.call(Context.java:515)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:507)
at com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:921)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandlersIfNeeded(HtmlPage.java:1206)
at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize(HtmlPage.java:173)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:445)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:327)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:384)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:369)
at com.sutrosoftware.portalspy.http.NTLMConnection.login(NTLMConnection.java:53)
... 12 more
Caused by: org.mozilla.javascript.WrappedException: Wrapped java.lang.Exception: Automation server can't create object (script in http://cgportcl1/portal/site/cooley/template.DM/ from (145, 62) to (273, 18)#200)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1773)
at com.gargoylesoftware.htmlunit.javascript.host.ActiveXObject.jsConstructor(ActiveXObject.java:127)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:419)
at org.mozilla.javascript.BaseFunction.construct(BaseFunction.java:338)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3377)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2487)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:192)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)
at com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:82)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:472)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:437)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:507)
... 30 more
Caused by: java.lang.Exception: Automation server can't create object

There seems to be some regression in the way that htmlunit is handling an ActiveX component on the login page. Unfortunately I can't give many details at the moment about that component. However, here is some of the login page HTML as printed to the htmlunit debug logs. This section of the log comes right before the exception happens:

2009-03-18 15:43:02,130 [SwingWorker-pool-30538087-thread-5] DEBUG com.gargoylesoftware.htmlunit.html.HtmlScript - Script node added: <script language="JavaScript" type="text/javascript">
//<![CDATA[

    <!--
    function SelectDMDoc()
                    {
                    var rc;
                    var picker;

                    //Display the DM Extensions QuickRetrieve
                    picker =new ActiveXObject( "FDSDM.FDSDMAx" );
                    //picker.DMSType="DOCSOpen"; //optional, override to specify DOCS Open "DOCSOpen" or "DM"
                    //picker.SelectVersion=1; // 0 will assume latest version, and not ask, 1 will show versions
                    //picker.FolderSearch=1;  // optional [DM Only], 1=all folders search, 0= recent edits
                    //picker.Caption="Select Document/Clause...";  //optional for DM, not used for DOCS Open

                    // picker.DRF will contain a string of the document reference

                    rc=picker.getdoc();
                    if (rc==0)
                    {
                            // Set the value of the first element of the first form on the page:
                            document.forms[0].elements[0].value = picker.DRF;
                    }

                    // we can get error info like this:
                    //alert("rc=" + rc + "err=" + picker.ErrorDescription);
                    // or document details like this:
                    //alert("Document is " + picker.strDocumentName);

                    }

    function fnLoad()
    {
    //alert("cookie;" + readCookie("AX"));

            var fds;

            // before we process ActiveX, see if we are an auto-redirecting view request....
            if (getStringVar("action")=="view")
            {
                    //update: detect non Ax here, and launch fds link
                    if (readCookie("AX")!="true")
                    {
                            //alert("non-ax");
                            window.location="http://" + document.domain + "/fds/fds.aspx?lib=" + getStringVar("lib") + "&doc=" + getStringVar("doc");

                            quit();
                    }

            }

            // Now continue with the ActiveX items...
            fds=new ActiveXObject( "FDSDM.FDSDMAx" );
            fds.Library=getStringVar("lib");
            fds.DocNumber=getStringVar("doc");
            fds.FilePath=getStringVar("importpath");
            fds.DocAction("init");

            var expiration = new Date();
            expiration.setMonth( 1 );
            expiration.setDate( 1 );
            expiration.setYear( 2040);
            expiration.setHours( 12 );
            expiration.setMinutes( 00 );
            expiration.setSeconds( 00 );

            document.cookie = "DST=" + fds.DST + ";path=/;expires=" + expiration;
            //cookie to say we have ActiveX
            //we should fail before this point with no ActiveX, so write an OK cookie
            document.cookie = "AX=true;path=/;expires=" + expiration;

            //cookie to save search libraries
            document.cookie = "LIBS=" + fds.SearchLibs + ";path=/;expires=" + expiration;

            //alert(document.cookie);
            //now close this window, since we handled our request
            //window.close();

            if (getStringVar("action")=="import")
            {

                    // set iFrame values for caller
                    window.parent.document.composeform.file_name.value = fds.DocumentName;
                    //window.parent.document.composeform.card_url_protocol.value="http://";
                    window.parent.document.composeform.card_url_body.value=document.domain + "/fds/fds.aspx?lib=" + fds.Library + "&doc=" + fds.DocNumber;
                    window.parent.document.composeform.docid.value = fds.DocNumber;
                    window.parent.document.composeform.lib.value = fds.Library;
                    window.parent.document.composeform.success.value = fds.DocActionResult;
            }

    }

    function getStringVar(st)
    {
            var temp = self.document.location.search;
            if(temp.indexOf(st) >= 0)
            {
                    temp = temp.substring((temp.indexOf(st)+(st.length+1)), temp.length);
                    temp = temp.substring(0,                        (((temp.indexOf('&')>=0)?temp.indexOf('&'):temp.length)));

            }
                    else
            {
                     temp = '';
            }
            return unescape(temp);
    }

    function readCookie(name)
    {
            var nameEQ = name + "=";
            var ca = document.cookie.split(';');
            for(var i=0;i < ca.length;i++)
            {
                    var c = ca[i];
                    while (c.charAt(0)==' ') c = c.substring(1,c.length);
                    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
            }
            return null;
    }
    -->

//]]>
</script>

2009-03-18 15:43:02,146 [SwingWorker-pool-30538087-thread-5] DEBUG com.gargoylesoftware.htmlunit.html.HtmlBody - Firing Event propertychange (Current Target: HTMLElement for HtmlBody[<body marginheight="0" leftmargin="0" topmargin="0" onload="fnLoad();" marginwidth="0" rightmargin="0" bottommargin="0">]);

2009-03-18 15:43:02,146 [SwingWorker-pool-30538087-thread-5] DEBUG com.gargoylesoftware.htmlunit.html.HtmlHtml - Firing Event load (Current Target: HTMLElement for HtmlHtml[<html xmlns="http://www.w3.org/1999/xhtml">]);

2009-03-18 15:43:02,162 [SwingWorker-pool-30538087-thread-5] DEBUG com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer - Executing load handler for HtmlPage(http://cgportcl1/portal/site/cooley/template.DM/)@8447493

I would like to upgrade to the latest version of htmlunit, but for the time being I have had to revert back to 1.14 because of this issue. If anyone can shed any light on this issue -- either by providing a workaround or a bugfix -- I would be grateful.

Discussion

  • Daniel Gredler

    Daniel Gredler - 2009-03-22

    Can you provide a small (less than 20 lines, if possible) HTML page as an attachment which exhibits the behavior when loaded with HtmlUnit? Otherwise, we're probably not going to be able to help you...

     
  • SourceForge Robot

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 30 days (the time period specified by
    the administrator of this Tracker).

     

Log in to post a comment.