Hi
On 15/02/13 08:19, eanbiso wrote:
Hi all,
I have this problem using cxf dispatching behavior.
I have developed an Interceptor that implements the
org.apache.cxf.jaxrs.ext.RequestHandler interface.
In its "public Response handleRequest(Message m, ClassResourceInfo
resourceClass)" method I throw an exception (e.g. a WebServiceException) or
a Fault. I have not apparent problems but, on the client side, the client
receives a different exception (a ServerWebApplicationException) with the
error message empty.
Here the code:
Server side:
public class RestInterceptor implements RequestHandler {
......
@Override
public Response handleRequest(Message m, ClassResourceInfo
resourceClass){
.....
throw new WebServiceException("Failure in the dispatching ws
invocation!");
.....
}
}
ServerWebApplicationException received on client side:
Status : 500
Headers :
Content-Length : 0
Connection : close
Server : Jetty(7.x.y-SNAPSHOT)
cause=null
detailMessage=null
errorMessage=""
.....
I received the same exception also if I throw a Fault.
What is the problem? I have to use another exception? Why?
Thanks a lot,
When the exception escapes in the JAX-RS chain it is propagated by
default to the underlying container and thus you see just 500.
What you can do is to register a JAX-RS ExceptionMapper and map a given
exception to JAX-RS Response as required, or you can simply return
Response from your handler and it will block the invocation and return
this custom Response to the client
HTH, Sergey
Andrea
--
View this message in context:
http://cxf.547215.n5.nabble.com/How-to-throw-an-exception-from-public-Response-handleRequest-Message-m-ClassResourceInfo-resourceCla-tp5723225.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com