viernes, 22 de junio de 2012

HtmlUnit - Desactivar trazas de advertencia de css y javascript

Añadir el siguiente código:
LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
De ésta forma ya no veremos más en la consola las (molestas) trazas de HtmlUnit del tipo:
21-jun-2012 17:26:01 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify ADVERTENCIA: Obsolete content type encountered: 'application/x-javascript'. 21-jun-2012 17:26:01 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify ADVERTENCIA: Obsolete content type encountered: 'application/x-javascript'. 21-jun-2012 17:26:02 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify ADVERTENCIA: Obsolete content type encountered: 'application/x-javascript'. 21-jun-2012 17:26:02 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify ADVERTENCIA: Obsolete content type encountered: 'application/x-javascript'. 21-jun-2012 17:26:02 com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine handleJavaScriptException INFO: Caught script exception ======= EXCEPTION START ======== EcmaError: lineNumber=[797] column=[0] lineSource=[] name=[ReferenceError] sourceName=[script in http://aURL from (794, 64) to (798, 12)#797)] com.gargoylesoftware.htmlunit.ScriptException: ReferenceError: "flush" is not defined. (script in http://aURL from (794, 64) to (798, 12)#797) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:595) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:499) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:474) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:870) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:302) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:368) at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:230) at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:240) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:598) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:556) at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1142) at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1044) at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206) at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:329) at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3018) at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2005) at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:908) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:789) at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:225) at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:179) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:221) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:106) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:433) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:311) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:373) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:358) at es.cuponet.AirfastScrapper.main(AirfastScrapper.java:115) Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: ReferenceError: "flush" is not defined. (script in http://aURL from (794, 64) to (798, 12)#797) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3790) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3768) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3852) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntime.java:2239) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1505) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:854) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:164) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:429) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:267) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3183) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:175) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:490) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:589) ... 32 more Enclosed exception: net.sourceforge.htmlunit.corejs.javascript.EcmaError: ReferenceError: "flush" is not defined. (script in http://aURL from (794, 64) to (798, 12)#797) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3790) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3768) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3852) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntime.java:2239) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1505) at script(script in http://aURL from (794, 64) to (798, 12):797) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:854) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:164) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:429) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:267) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3183) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:175) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:490) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:589) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:499) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:474) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:870) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:302) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:368) at com.gargoylesoftware.htmlunit.html.HtmlScript$1.execute(HtmlScript.java:230) at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:240) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:598) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:556) at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1142) at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1044) at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206) at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:329) at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3018) at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2005) at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:908) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:789) at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:225) at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:179) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:221) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:106) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:433) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:311) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:373) at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:358) at es.cuponet.AirfastScrapper.main(AirfastScrapper.java:115) ======= EXCEPTION END ======== 21-jun-2012 17:26:02 com.gargoylesoftware.htmlunit.IncorrectnessListenerImpl notify ADVERTENCIA: Obsolete content type encountered: 'application/x-javascript'. 21-jun-2012 17:26:03 com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error ADVERTENCIA: CSS error: [563:46] Error in expression. Invalid token "=". Was expecting one of: ...

1 comentario :

  1. gracias viejo de verdad me sirvió muchoo!!.. estoy en un proyecto con htmlunit y de verdad q son muy molestas.. XDD

    ResponderEliminar

Ay payo, coméntame algo, porfa...