Enhance CXF client message in case of HttpRetryException (http codes 401 and 
407)  
-----------------------------------------------------------------------------------

                 Key: CXF-2672
                 URL: https://issues.apache.org/jira/browse/CXF-2672
             Project: CXF
          Issue Type: Improvement
          Components: Core
    Affects Versions: 2.2.6
            Reporter: Cyrille Le Clerc


401 and 407 exceptions can be cumbersome to fix due to unclear message like 
_"java.net.HttpRetryException: cannot retry due to server authentication, in 
streaming mode"_. The most difficult trick is to figure out whether the conduit 
you configured is actually used or if is a default one due to a naming mistake.

The ideas of this enhancement are to add the url, http response code & message 
and the username that was used. When username is not defined, give the conduit 
name to ease fixing conduit naming mistakes.

{noformat:title=Current exception message for 401 with invalid login/password}
javax.xml.ws.WebServiceException: Could not send Message.
        at 
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
        at $Proxy69.sayHi(Unknown Source)
        ...
Caused by: java.net.HttpRetryException: cannot retry due to server 
authentication, in streaming mode
        at 
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1134)
        at 
java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
        ...
{noformat}

{noformat:title=New exception message for 401 with invalid login/password}
javax.xml.ws.WebServiceException: Could not send Message.
        at 
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
        at $Proxy69.sayHi(Unknown Source)
        ...
Caused by: java.io.IOException: HTTP response '401: Unauthorized' invoking 
http://example.com/services/myService with authorization username 'john'
        at 
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2027)
        ...
Caused by: java.net.HttpRetryException: cannot retry due to server 
authentication, in streaming mode
        at 
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1134)
        at 
java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
        ...
{noformat}

{noformat:title=New exception message for 401 with missing login/password}
javax.xml.ws.WebServiceException: Could not send Message.
        at 
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
        at $Proxy69.sayHi(Unknown Source)
        ...
Caused by: java.io.IOException:  HTTP response '401: Unauthorized' invoking 
http://example.com/services/myService with NO authorization username configured 
in conduit {http://ws.example.com/}MyServicePort.http-conduit
        at 
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2027)
        ...
Caused by: java.net.HttpRetryException: cannot retry due to server 
authentication, in streaming mode
        at 
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1134)
        at 
java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373)
        ...
{noformat}



{noformat:title=Current exception message for 407 with invalid login/password}
javax.xml.ws.WebServiceException: Could not send Message.
        at 
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
        at $Proxy69.sayHi(Unknown Source)
        ...
Caused by: java.net.HttpRetryException: cannot retry due to proxy 
authentication, in streaming mode
        at 
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1082)
        ...
{noformat}

{noformat:title=Current exception message for 407 with invalid login/password}
javax.xml.ws.WebServiceException: Could not send Message.
        at 
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
        at $Proxy69.sayHi(Unknown Source)
        ...
Caused by: java.io.IOException: HTTP response '407: Proxy Authentication 
Required' invoking http://localhost:8080/jmx-demo/exception/407 with proxy 
authorization username 'john' using HTTP proxy localhost:8888
        at 
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2028)
        ...
Caused by: java.net.HttpRetryException: cannot retry due to proxy 
authentication, in streaming mode
        at 
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1082)
        ...
{noformat}

{noformat:title=Current exception message for 407 with missing login/password}
javax.xml.ws.WebServiceException: Could not send Message.
        at 
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
        at $Proxy69.sayHi(Unknown Source)
        ...
Caused by: java.io.IOException: HTTP response '407: Proxy Authentication 
Required' invoking http://localhost:8080/jmx-demo/exception/407 with NO proxy 
authorization configured in conduit 
{http://ws.example.com/}MyServicePort.http-conduit using HTTP proxy 
localhost:8888
        at 
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2028)
        ...
Caused by: java.net.HttpRetryException: cannot retry due to proxy 
authentication, in streaming mode
        at 
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1082)
        ...
{noformat}




-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to