Hmm. It's possible, but I'm not accustomed to seeing ExceptionMappers
tied to clients, my experience as yet with them is that they're
exclusively on the service side and used to define response codes to
return to the client for specific service-side exceptions raised.
WebClient is a CXF-specific convenience construct for making REST calls,
not defined in the JAX-RS specification. (Other REST stacks tend to
have their own "WebClient"-type convenience objects.) So I can't see the
JAX-RS specification defining the behavior of adding ExceptionMappers to
WebClients, given that the latter from the perspective of the
specification doesn't exist.
Glen
On 02/27/2012 09:01 PM, ur_afroinu wrote:
Hello forum,
I have a custom ResponseExceptionMapper, which would construct appropriate
Exception instance from response InputStream (from response.getEntity()).
I registered the instance as one of the providers to WebClient but upon
request error, what I get is
"org.apache.cxf.jaxrs.client.ServerWebApplicationException".
I have a simplified version of my code below. If you could point out what
I'm doing wrong, I'd very much appreciate it.
Best regards.
CXF: 2.4.0
---------------------------------------------------------
public void test(String endpointBaseUrl) throws Exception {
ResponseExceptionMapper<Throwable> responseExceptionMapper = new
ResponseExceptionMapper<Throwable>() {
@Override
public Throwable fromResponse( Response r ) {
System.out.println("fromResponse called");
return new CustomException("status="+r.getStatus());
}
};
//ProviderFactory.getInstance().registerUserProvider(
responseExceptionMapper );
java.util.List providers = new java.util.ArrayList();
providers.add( new
org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider() );
providers.add( responseExceptionMapper );
try {
WebClient client = WebClient.create( endpointBaseUrl, providers
);
client = client.accept( "application/json" ).type(
"application/json" ).path( _username ).path( "authenticate"
).query("password", _password);
User user = client.get( User.class);
//assertNotNull( user );
fail();
} catch (CustomException e) {
// expected...
} catch (Exception e) {
fail();
}
}
---------------------------------------------------------
--
View this message in context:
http://cxf.547215.n5.nabble.com/WebClient-ResponseExceptionMapper-provider-mapper-is-not-being-called-tp5520604p5520604.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Glen Mazza
Talend Community Coders - coders.talend.com
blog: www.jroller.com/gmazza