cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Willard, Jonathan" <>
Subject RE: Problem with Exception handling in Jaxrs web services.
Date Thu, 10 Jun 2010 13:07:08 GMT
There are some useful tools on the net for testing. You might want to
check out the RestClient at under
'Featured Downloads' on the right.  It is more useful than the browswer.


-----Original Message-----
From: Sunil Dhage [] 
Sent: Thursday, June 10, 2010 2:46 AM
Subject: RE: Problem with Exception handling in Jaxrs web services.

Thanks guys.

I got the problem solved.  What I was doing was "Testing using Mozilla
Firefox and it was not showing in any way the response status code."
My resolution steps are as follows:
1. First tested using telnet and sending HTTP Get invocation, I was
getting the expected resonse status code.
2. Then I used Internet Explorer and I got the response code as

Sunil Kumar Dhage.

-----Original Message-----
From: Sunil Dhage [] 
Sent: Wednesday, June 09, 2010 1:11 PM
Subject: Problem with Exception handling in Jaxrs web services.

Hi, All the members of the users list,

I am a newbie to the users list and my issue is regarding exception
handling in Rest web services.

I am trying to handle exceptions in my Resource methods as mentioned in
My code is

public Employees getAllEmployees(int noOfEmps) {
        if (noOfEmps == 0){
            throw new WebApplicationException(403);
        return null;

    public Response addEmployees(int empId){
        if (empId == 0){
            return Response.status(403).build();
        return Response.ok().build();

When I test using my browsers neither of the service methods come with
the response code 403.
And when I generate my wadl by
<method name="GET">
<representation mediaType="application/xml"/>
But it should show different response entries like

<response status ="403">
<response status = "200">

Then I tried mapping the exceptions as below

public class ExceptionMapperProvider implements
        ExceptionMapper<WebApplicationException> {
    public Response toResponse(WebApplicationException ex) {
        return Response.status(ex.getResponse().getStatus()).

And registered this provider with the <jaxrs:providers> in my cxf.xml.

Still I am neither
 getting the response with status code 403
WADL containing different response status codes.

Please help me in finding what am I missing out here.

Sunil Kumar Dhage.

View raw message