Re: Java exception when validating page with redirection

Hi Jaime,

I've noticed the same when using the .jar version of the validator from 
the command line.

This is related to redirection but not in relation to a new domain.

This occurs when a HTTP location header specifies a relative URL instead 
of an absolute URL. The validator doesn't appear to attempt to translate 
relative location header URLs into absolute URLs. In trying to parse 
and/or use the provided relative URL, an exception is raised as both the 
protocol and host parts of the URL are missing.

Location headers must provide an absolute URL (according to rfc2616 
section 14.30) and so it could be argued that the validator is correct 
in not translating relative URLs to absolute URLs. Personally I feel it 
should try to correct such URLs but that's a subjective matter that 
could spawn an almost endless off-topic discussion that's not relevant here.

As a workaround I use a wrapper to call the command line .jar version of 
the validator. Cases where the validator fails in situations such as the 
one you describe are identified. The wrapper translates the discovered 
relative URL into the correct absolute URL and tries again.

In short, you can't necessarily fix this in the validator but you can 
sensibly work around the issue in the application you use that makes use 
of the validator.

Cheers,
Jon

In cases where

On 18/04/13 21:04, Jaime Iniesta wrote:
> Hi, I've installed the CSS validator following this guide:
>
> https://github.com/tlvince/w3c-css-validator-guide
>
> Overall it works fine, but I'm getting a weird java exception when 
> validating this URL
>
> http://elpais.com/internacional
>
> I get this message:
>
> ####################
> Target: http://elpais.com/internacional/
> java.lang.IllegalArgumentException: protocol = http host = null
> ####################
>
> And this the error backtrace I see on catalina.out:
>
> #################################################
> [ERROR VALIDATOR] http://elpais.com/internacional/
> java.lang.IllegalArgumentException: protocol = http host = null
> java.lang.IllegalArgumentException: protocol = http host = null
> at sun.net.spi.DefaultProxySelector.select(DefaultProxySelector.java:170)
> at 
> sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:925)
> at 
> sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:849)
> at org.w3c.css.util.HTTPURL.getConnection(HTTPURL.java:257)
> at org.w3c.css.util.HTTPURL.getConnection(HTTPURL.java:276)
> at org.w3c.css.util.HTTPURL.getConnection(HTTPURL.java:276)
> at org.w3c.css.util.HTTPURL.getConnection(HTTPURL.java:312)
> at org.w3c.css.css.DocumentParser.<init>(DocumentParser.java:124)
> at org.w3c.css.servlet.CssValidator.doGet(CssValidator.java:363)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
> at 
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> at 
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
> at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> at 
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
> at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
> at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> at 
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
> at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> at 
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
> at 
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
> at 
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> at java.lang.Thread.run(Thread.java:722)
> #########################################
>
> I don't see this error on the official validator at 
> http://jigsaw.w3.org/css-validator/
>
> It looks like it might be caused by the redirection to a different domain.
>
> Any idea how to fix this?
>
> Thanks!
>
> Jaime
>
>

Received on Friday, 19 April 2013 08:05:13 UTC