Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-519

Http code 200 is set the response instead of 400 upon JAXBMarshalException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor Minor
    • 2.2.RC1
    • 2.1.0.GA
    • jaxrs
    • None
    • Hide

      Test case available upon request

      Show
      Test case available upon request
    • Workaround Exists
    • Hide

      just create a Exception Mapper like below :

      @Provider
      @Named
      public class JaxBMarshalExceptionMapper implements ExceptionMapper<JAXBMarshalException>
      {
      
      	@Override
      	public Response toResponse(JAXBMarshalException exception)
      	{
      		ErrorType error = ErrorUtil.createErrorType(exception);
      		return Response.status(Status.BAD_REQUEST).entity(error).build();
      	}
      }
      
      Show
      just create a Exception Mapper like below : @Provider @Named public class JaxBMarshalExceptionMapper implements ExceptionMapper<JAXBMarshalException> { @Override public Response toResponse(JAXBMarshalException exception) { ErrorType error = ErrorUtil.createErrorType(exception); return Response.status(Status.BAD_REQUEST).entity(error).build(); } }

      According to the Resteasy documentation, the Resteasy Built-in Internally-Thrown Exceptions section , the exception _:
      o.j.r.plugins.providers.jaxb.JAXBMarshalException is mapped with the Status code 500.
      http://docs.jboss.org/resteasy/docs/2.0.0.GA/userguide/html/ExceptionHandling.html

      This of course happens when NO Exception mapper is available. Unfortunalty this does not seems to be correct , as a Status 200 is set to the Response , after debugging , the Status 200 is defined in HttpServletResponseWrapper.

      This happens if a Post of a malformed xml request (Upon POST),ideally it may be a BAD_REQUEST (400)

              patriot1burke@gmail.com Bill Burke (Inactive)
              anis.moussa Anis Moussa (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: