question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: Exception: java.lang.NullPointerException in HtmlUnit 2.43

See original GitHub issue

Getting the below exception while calling getPage for url: https://investors.alticeusa.com/investors/alticeusa/results-and-presentations/default.aspx using HtmlUnit 2.43.0 version but version 2.23 is not throwing the exceptions. Exception in thread "main" net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: Exception: java.lang.NullPointerException at net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:1040) at net.sourceforge.htmlunit.corejs.javascript.Context.reportRuntimeError(Context.java:1090) at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.loadStylesheet(CSSStyleSheet.java:410) at com.gargoylesoftware.htmlunit.javascript.host.html.HTMLLinkElement.getSheet(HTMLLinkElement.java:143) at com.gargoylesoftware.htmlunit.html.HtmlLink$1.execute(HtmlLink.java:311) at com.gargoylesoftware.htmlunit.html.HtmlLink.onAllChildrenAddedToPage(HtmlLink.java:321) at com.gargoylesoftware.htmlunit.html.parser.neko.HtmlUnitNekoDOMBuilder.endElement(HtmlUnitNekoDOMBuilder.java:560) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at com.gargoylesoftware.htmlunit.html.parser.neko.HtmlUnitNekoDOMBuilder.endElement(HtmlUnitNekoDOMBuilder.java:514) at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source) at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.startElement(HTMLTagBalancer.java:773) at net.sourceforge.htmlunit.cyberneko.HTMLTagBalancer.emptyElement(HTMLTagBalancer.java:820) at net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter.emptyElement(DefaultFilter.java:145) at net.sourceforge.htmlunit.cyberneko.filters.NamespaceBinder.emptyElement(NamespaceBinder.java:310) at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scanStartElement(HTMLScanner.java:2769) at net.sourceforge.htmlunit.cyberneko.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2117) at net.sourceforge.htmlunit.cyberneko.HTMLScanner.scanDocument(HTMLScanner.java:927) at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:506) at net.sourceforge.htmlunit.cyberneko.HTMLConfiguration.parse(HTMLConfiguration.java:459) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at com.gargoylesoftware.htmlunit.html.parser.neko.HtmlUnitNekoDOMBuilder.parse(HtmlUnitNekoDOMBuilder.java:760) at com.gargoylesoftware.htmlunit.html.parser.neko.HtmlUnitNekoHtmlParser.parse(HtmlUnitNekoHtmlParser.java:208) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:283) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:163) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:638) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:451) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:368) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:520) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:501) at com.factset.htmlunit.testapp.main(testapp.java:99)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rbricommented, Oct 20, 2020

for me it looks like the problem is in your code

if (((response.getStatusCode() != 200) && !url.equalsIgnoreCase(initialUrl))
    && (response.getStatusCode() != 302) && (response.getStatusCode() != 301)) {
    System.out.println("create an empty web response in order to ignore exception due to this : "
            + response.getStatusCode() + " " + response.getStatusMessage() + " " + url);
    response = null;
}
String origCharset = (response.getContentCharset()).toString();

If you code sets the response to null, the next line after the if block will produce the NPE.

0reactions
sowjanyaboddeticommented, Oct 21, 2020

Working now. Thanks for your help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullPointerException in handleJavaScriptException · Issue #136
Thread.run(Thread.java:748) [?:1.8.0_232] Caused by: java.lang.RuntimeException: Exception invoking setHref at net.sourceforge.htmlunit.corejs.javascript.
Read more >
Changes - HtmlUnit - SourceForge
Use our own simple color class to reduce the java.awt dependencies. rbri. Remove, Element behaviors and HTML components (HTCs) have been removed from...
Read more >
HtmlUnit NullPointerException - java - Stack Overflow
gtFirstByXPath returns an NullPointerException but I'm sure 'form action' exists as you can see. is htmlUnit syntax corret ? Thanks. java ...
Read more >
HtmlUnit / Bugs / #1589 java.lang.NullPointerException in ...
I am copying the junit test that recreates the problem. The stack trace: Exception in thread "main" net.sourceforge.htmlunit.corejs.javascript.
Read more >
JavaScriptEngine (HtmlUnit 2.32 API) - javadoc.io
Compiles the specified JavaScript code in the context of a given scope. net.sourceforge.htmlunit.corejs.javascript.Script, compile(HtmlPage page, String ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found