HtmlUnit is not loading javascript and failing with following error,
XXXX com.gargoylesoftware.htmlunit.ScriptException: Exception invoking send
at
com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:892)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:616)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:534)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:772)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:748)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:739)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScript(HtmlPage.java:922)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:316)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:396)
at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:246)
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:267)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:802)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:758)
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1194)
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1134)
at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:221)
at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:314)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3179)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2132)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:939)
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:452)
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:403)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:1001)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:250)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:196)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:267)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:158)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:531)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:398)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:315)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:466)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:448)
Tried using different browser options.
Page loads fine in browser. As it's failing to load javascript, I don't get the javascript generated content. Thanks
For analyzing this i need more details
Thanks for your response. Following is the whole stack and it also has the URL which I am connecting to,
[10-17-18 12:20:48] I Logging in with IBM Id - User xxxx@gmail.com
[10-17-18 12:20:48] I IBM Id Login - Step 1: Opening "IBMid - Sign in to IBM" page at "https://commerceinsights.ibmcloud.com/cw/resources/userSession/login"
[10-17-18 12:20:51] E com.ibm.jmonitor.insights.ibmid.WCILogin._phaseIBMIdLogin() ERROR: Unable to login with IBM id due to com.gargoylesoftware.htmlunit.ScriptException: Exception invoking send
[10-17-18 12:20:51] E com.ibm.jmonitor.tester.Result.endTest(Exception e) ERROR: com.gargoylesoftware.htmlunit.ScriptException: Test IBMId_0 failed
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:892)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:616)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:534)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:772)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:748)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:739)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScript(HtmlPage.java:922)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:316)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:396)
at com.gargoylesoftware.htmlunit.html.HtmlScript$2.execute(HtmlScript.java:246)
at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:267)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:802)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:758)
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1194)
at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1134)
at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.endElement(DefaultFilter.java:221)
at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.endElement(NamespaceBinder.java:314)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3179)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2132)
at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:939)
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:452)
at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:403)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:1001)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:250)
at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:196)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:267)
at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:158)
at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:531)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:398)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:315)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:466)
at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:448)
at com.ibm.jmonitor.web.Browser.getPage(Browser.java:167)
at com.ibm.jmonitor.web.Browser.getHtmlPage(Browser.java:142)
at com.ibm.jmonitor.web.IBMIdLogin.issueIBMIdLogin(IBMIdLogin.java:55)
at com.ibm.jmonitor.insights.ibmid.WCILogin.login(WCILogin.java:42)
at com.ibm.jmonitor.insights.tests.Test_IBMId.runTest(Test_IBMId.java:45)
at com.ibm.jmonitor.tester.Test.call(Test.java:147)
at com.ibm.jmonitor.tester.Test.call(Test.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
When I set not to throw above javascript error ( webClient.getOptions().setThrowExceptionOnScriptError(false);) then I get the following as page xml, which doesn't have all fields as java script failed to execute.
@RBRi, Please let me know if you need any further information on this. Thanks
Maybe yes;
I need the real cause of the problem. Can you please set a JavaScriptErrorListener for your client and implement the method scriptException() in your error listener. Then debug or make sure to dump the whole throwable parameter including all cases.
Background: In Rhino all the js support is implemented in Java methods, and these methods are called via reflection. In your case one of the java methods throws an error (e.g NPE) but this error is wrapped as cause along the way up to rhino. I need this cause to figure out what is going on.
@RBRi, Apologies for delayed response. I get the following details when print the scriptException,
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot modify readonly property: constructor. (https://www.ibm.com/account/ibmidutil/js/idaas/duo/static/js/login.min.js#1)
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot modify readonly property: constructor. (https://www.ibm.com/account/ibmidutil/js/idaas/duo/static/js/login.min.js#1)
com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot modify readonly property: constructor. (https://www.ibm.com/account/ibmidutil/js/idaas/duo/static/js/login.min.js#1)
com.gargoylesoftware.htmlunit.ScriptException: Exception invoking send
com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: Exception invoking send (script in https://idaas.iam.ibm.com/idaas/oidc/endpoint/default/authorize?response_type=code&client_id=ZDg2MjRmMjYtNjRjNi00&state=001541615179266rEiXIP0nw&redirect_uri=https%3A%2F%2Fcommerceinsights.ibmcloud.com%2Foidcclient%2Fredirect%2Fibmid&scope=openid from (5, 9) to (42, 10)#35)
com.gargoylesoftware.htmlunit.ScriptException: Exception invoking send
com.gargoylesoftware.htmlunit.ScriptException: Exception invoking send
Last edit: Senthil K Ponnusamy 2018-11-07
@RBRi, Any update on this?
Are you looking for more information on this? Thx
Sorry too many open threads....
Cannot modify readonly property: constructor
This seems to be more or less teh same problem as https://sourceforge.net/p/htmlunit/bugs/1897/. Because we are using Rhino and there are some problems with the support of more modern js i guess there will be not that much progress during the next weeks.
If you like to help it will be great if you can check if the problem is the same as in the issue mentioned above. And of course any PullRequests for Rhino and or HtmlUnit are welcome.
Yeah, I checked it before and it looks like the same issue.