cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahazelton <ahazel...@axeda.com>
Subject ExceptionMapper causing subsequent ClassCastExceptions
Date Thu, 10 Feb 2011 19:50:16 GMT

I have a service method like this:
  @Override
  @POST
  @Path("/model/create")
  public Long createModel(Model model)
  {
    ...
  }

I registered an exception mapper like this:
public class CustomWebApplicationExceptionMapper extends
AbstractRestExceptionMapper implements
ExceptionMapper<WebApplicationException> {
  @Override
  public Response toResponse(WebApplicationException exception)
  {
       Response response =
Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_XML).entity(someString).build();
      return response;
    }
    ...
  }
}

And registered the mapper as a jaxrs:provider:
   <jaxrs:providers>
      ...
      <ref bean="CustomWebApplicationExceptionMapper"/>
   </jaxrs:providers>

I have verified that in the debugger my exception mapper is getting called
and the expected response generated.  Unfortunately when this response is
sent back to the client the JAXRSOutInterceptor is triggering a
ClassCastException.  It appears to be because the service method returns a
Long and the Response object is a String.  I changed the service method
return type above from a Long to a String and the class cast goes away.

How can I use an ExceptionMapper for any method, regardless of its return
type?

-- 
View this message in context: http://cxf.547215.n5.nabble.com/ExceptionMapper-causing-subsequent-ClassCastExceptions-tp3379990p3379990.html
Sent from the cxf-issues mailing list archive at Nabble.com.

Mime
View raw message