What is causing this error, and how do I fix it?
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage("http://stackoverflow.com");
Error message
May 25, 2013 10:34:12 AM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'text/javascript'. May 25, 2013 10:34:13 AM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError SEVERE: runtimeError: message=[The data necessary to complete this operation is not yet available.] sourceName=[http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js] line=[2] lineSource=[null] lineOffset=[0] May 25, 2013 10:34:15 AM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'text/javascript'. May 25, 2013 10:34:16 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error WARNING: CSS error: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:3230] Error in style rule. (Invalid token "!". Was expecting one of: , , , "inherit", , , , , , , , , , , , , , , , , , , , , , , , , , "}", ";", "/", "-".) May 25, 2013 10:34:16 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning WARNING: CSS warning: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:3230] Ignoring the following declarations in this rule. May 25, 2013 10:34:16 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error WARNING: CSS error: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:6341] Error in style rule. (Invalid token "!". Was expecting one of: , , , "inherit", , , , , , , , , , , , , , , , , , , , , , , , , , "}", ";", "/", "-".) May 25, 2013 10:34:16 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning WARNING: CSS warning: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:6341] Ignoring the following declarations in this rule. May 25, 2013 10:34:16 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error WARNING: CSS error: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:14777] Error in style rule. (Invalid token "!". Was expecting one of: , , , "inherit", , , , , , , , , , , , , , , , , , , , , , , , , , "}", ";", "/", "-".) May 25, 2013 10:34:16 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning WARNING: CSS warning: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:14777] Ignoring the following declarations in this rule. May 25, 2013 10:34:17 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error WARNING: CSS error: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:31657] Error in style rule. (Invalid token "!". Was expecting one of: , , , "inherit", , , , , , , , , , , , , , , , , , , , , , , , , , "}", ";", "/", "-".) May 25, 2013 10:34:17 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning WARNING: CSS warning: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:31657] Ignoring the following declarations in this rule. May 25, 2013 10:34:17 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error WARNING: CSS error: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:73253] Error in style rule. (Invalid token ":". Was expecting one of: , , , "inherit", , , , , , , , , , , , , , , , , , , , , , , , , , "}", ";", "/", "-".) May 25, 2013 10:34:17 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning WARNING: CSS warning: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:73253] Ignoring the following declarations in this rule. May 25, 2013 10:34:17 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error WARNING: CSS error: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:112886] Error in expression. (Invalid token "#ffffff". Was expecting one of: , , , , , , , "-", "=", ")".) May 25, 2013 10:34:17 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error WARNING: CSS error: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:112928] Error in style rule. (Invalid token "background". Was expecting one of: , "}", ";".) May 25, 2013 10:34:17 AM com.gargoylesoftware.htmlunit.DefaultCssErrorHandler warning WARNING: CSS warning: 'cdn.sstatic.net/stackoverflow/all.css?v=1748204ca390' [1:112928] Ignoring the following declarations in this rule. May 25, 2013 10:34:19 AM com.gargoylesoftware.htmlunit.javascript.host.ActiveXObject jsConstructor WARNING: Automation server can't create object for 'ShockwaveFlash.ShockwaveFlash.7'. May 25, 2013 10:34:19 AM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError SEVERE: runtimeError: message=[Automation server can't create object for 'ShockwaveFlash.ShockwaveFlash.7'.] sourceName=[http://www.google-analytics.com/ga.js] line=[25] lineSource=[null] lineOffset=[0] May 25, 2013 10:34:19 AM com.gargoylesoftware.htmlunit.javascript.host.ActiveXObject jsConstructor WARNING: Automation server can't create object for 'ShockwaveFlash.ShockwaveFlash.6'. May 25, 2013 10:34:19 AM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError SEVERE: runtimeError: message=[Automation server can't create object for 'ShockwaveFlash.ShockwaveFlash.6'.] sourceName=[http://www.google-analytics.com/ga.js] line=[25] lineSource=[null] lineOffset=[0] May 25, 2013 10:34:19 AM com.gargoylesoftware.htmlunit.javascript.host.ActiveXObject jsConstructor WARNING: Automation server can't create object for 'ShockwaveFlash.ShockwaveFlash'. May 25, 2013 10:34:19 AM com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter runtimeError SEVERE: runtimeError: message=[Automation server can't create object for 'ShockwaveFlash.ShockwaveFlash'.] sourceName=[http://www.google-analytics.com/ga.js] line=[25] lineSource=[null] lineOffset=[0] May 25, 2013 10:34:20 AM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'application/x-javascript'. May 25, 2013 10:34:21 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies WARNING: Invalid cookie header: "Set-Cookie: azk-views=; Max-Age=31536000000; Path=/; Expires=Sun, 25 May 2014 17:34:42 GMT". Invalid max-age attribute: 31536000000 May 25, 2013 10:34:21 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies WARNING: Invalid cookie header: "Set-Cookie: azk-events=; Max-Age=2592000000; Path=/; Expires=Mon, 24 Jun 2013 17:34:42 GMT". Invalid max-age attribute: 2592000000 May 25, 2013 10:34:21 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies WARNING: Invalid cookie header: "Set-Cookie: azk-voting=; Max-Age=2592000000; Path=/; Expires=Mon, 24 Jun 2013 17:34:42 GMT". Invalid max-age attribute: 2592000000 May 25, 2013 10:34:21 AM com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify WARNING: Obsolete content type encountered: 'text/javascript'. May 25, 2013 10:34:23 AM com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl runSingleJob SEVERE: Job run failed with unexpected RuntimeException: Exception invoking setInnerHTML
Those are not errors, they are warnings.
They are caused by HtmlUnit's JavaScript engine Mozilla’s Rhino being unable to properly interpret some JavaScript code. (It is not as "good" as some other popular JS Engines.)
You can turn those warnings off, here's how:
public static void main(String[] args) throws Exception {
// turn off htmlunit warnings
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.OFF);
java.util.logging.Logger.getLogger("org.apache.http").setLevel(java.util.logging.Level.OFF);
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage("http://stackoverflow.com");
System.out.println(page.getTitleText());
}
Output:
Stack Overflow
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With