Missed Context.javaToJS() conversion:

Help
chris judd
2008-07-02
2013-04-26
  • chris judd
    chris judd
    2008-07-02

    Hi

    I just started using httpunit 2 days ago and i am trying to access a simple website. Here is the code and the errors i get. I am out of my mind with these errors. I need REAL help really soon or i will fail my class

    WebConversation wc = new WebConversation();
    WebResponse resp = wc.getResponse( "http://www.ticketmaster.com" ); // read this page 
    HttpUnitOptions.setExceptionsThrownOnScriptError( false );
    WebResponse jdoc = wc.getCurrentPage(); 
    System.out.println("result is "+jdoc.getTitle());

    Errors::

    RHINO USAGE WARNING: Missed Context.javaToJS() conversion:
    Rhino runtime detected object [Ljava.lang.Object;@1edc073 of class [Ljava.lang.Object; where it expected String, Number, Boolean or Scriptable instance. Please check your code for missing Context.javaToJS() call.
    org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (httpunit#162)
    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3229)
    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3219)
    at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3235)
    at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3254)
    at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3267)
    at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1324)
    at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:2816)
    at script(httpunit:162)
    at script(httpunit:45)
    at script(httpunit:4)
    at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2251)
    at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:161)
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:340)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2758)
    at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:172)
    at org.mozilla.javascript.Context.evaluateString(Context.java:1132)
    at com.meterware.httpunit.javascript.ScriptingEngineImpl.runScript(ScriptingEngineImpl.java:92)
    at com.meterware.httpunit.scripting.ScriptableDelegate.runScript(ScriptableDelegate.java:88)
    at com.meterware.httpunit.parsing.NekoDOMParser.runScript(NekoDOMParser.java:151)
    at com.meterware.httpunit.parsing.ScriptFilter.getTranslatedScript(ScriptFilter.java:150)
    at com.meterware.httpunit.parsing.ScriptFilter.endElement(ScriptFilter.java:131)
    at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:249)
    at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:367)
    at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1015)
    at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:888)
    at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java:2831)
    at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809)
    at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478)
    at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:48)
    at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:271)
    at com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1301)
    at com.meterware.httpunit.WebResponse.getFrames(WebResponse.java:1285)
    at com.meterware.httpunit.WebResponse.getFrameRequests(WebResponse.java:1024)
    at com.meterware.httpunit.FrameHolder.updateFrames(FrameHolder.java:179)
    at com.meterware.httpunit.WebWindow.updateFrameContents(WebWindow.java:315)
    at com.meterware.httpunit.WebClient.updateFrameContents(WebClient.java:526)
    at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:201)
    at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183)
    at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)
    at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:125)
    at com.meterware.httpunit.WebClient.getResponse(WebClient.java:96)
    at ticketmasterrobot.Main.test(Main.java:42)
    at ticketmasterrobot.Main.main(Main.java:31)
    com.meterware.httpunit.ScriptException: Script 'var DateTime;
    var today=new Date();
    var DateTime = 's' + today.getFullYear() + today.getMonth() + today.getDate() +
    today.getHours() + today.getMinutes() + today.getSeconds();
    var so = new SWFObject("http://media.ticketmaster.com/en-us/img/sys/common_new/rotating_spotlight.swf", "promo", "595", "160", "8", "#ffffff");
    so.addVariable("nationalURL", escape("http://media.ticketmaster.com/xml/en-us/spotlight/promo_national_us.xml"));
    so.addVariable("localURL", "null"); so.addVariable("defaultURL", escape("http://media.ticketmaster.com/xml/en-us/spotlight/promo_default.xml" + '?' + DateTime)); so.addVariable("tm_link_nav_button", escape("tm_home_1_f"));
    so.addVariable("tm_link_image", escape("tm_home_2_f"));
    so.addVariable("tm_link_teaser_text", escape("tm_home_3_f"));
    so.addVariable("tm_link_action_text_button", escape("tm_home_4_f"));
    so.addVariable("fbImgPath", escape("http://media.ticketmaster.com/en-us/img/sys/common_new/alert_400x160_en-us.jpg"));
    so.addVariable("fbRedirectTo", escape("https://www.ticketmaster.com/member/customize_alerts"));
    so.addParam("allowscriptaccess", escape("always"));
    so.write("spotlight_wrapper");' failed: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "length" from undefined (httpunit#162)
    at com.meterware.httpunit.javascript.ScriptingEngineImpl.handleScriptException(ScriptingEngineImpl.java:64)
    at com.meterware.httpunit.javascript.ScriptingEngineImpl.runScript(ScriptingEngineImpl.java:95)
    at com.meterware.httpunit.scripting.ScriptableDelegate.runScript(ScriptableDelegate.java:88)
    at com.meterware.httpunit.parsing.NekoDOMParser.runScript(NekoDOMParser.java:151)
    at com.meterware.httpunit.parsing.ScriptFilter.getTranslatedScript(ScriptFilter.java:150)
    at com.meterware.httpunit.parsing.ScriptFilter.endElement(ScriptFilter.java:131)
    at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:249)
    at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:367)
    at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1015)
    at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:888)
    at org.cyberneko.html.HTMLScanner$SpecialScanner.scan(HTMLScanner.java:2831)
    at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:809)
    at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:478)
    at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:431)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    at com.meterware.httpunit.parsing.NekoHTMLParser.parse(NekoHTMLParser.java:48)
    at com.meterware.httpunit.HTMLPage.parse(HTMLPage.java:271)
    at com.meterware.httpunit.WebResponse.getReceivedPage(WebResponse.java:1301)
    at com.meterware.httpunit.WebResponse.getFrames(WebResponse.java:1285)
    at com.meterware.httpunit.WebResponse.getFrameRequests(WebResponse.java:1024)
    at com.meterware.httpunit.FrameHolder.updateFrames(FrameHolder.java:179)
    at com.meterware.httpunit.WebWindow.updateFrameContents(WebWindow.java:315)
    at com.meterware.httpunit.WebClient.updateFrameContents(WebClient.java:526)
    at com.meterware.httpunit.WebWindow.updateWindow(WebWindow.java:201)
    at com.meterware.httpunit.WebWindow.getSubframeResponse(WebWindow.java:183)
    at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:158)
    at com.meterware.httpunit.WebWindow.getResponse(WebWindow.java:125)
    at com.meterware.httpunit.WebClient.getResponse(WebClient.java:96)