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

Incorrect http response codes upon errors when using RESTEasy-Spring integration

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 1.2.1.GA
    • 1.2.RC1
    • None
    • None

    Description

      When using RESTEasy Spring integration (by including the springmvc-resteasy.xml), the bean "resteasy.exception.handler" is configured to map the "org.jboss.resteasy.spi.NoResourceFoundFailure" to a "resteasy.no.resource.found.view" (bean for class org.jboss.resteasy.springmvc.ResteasyNoResourceFoundView).
      If the resteasy.handlerMapping is configured with throwNotFound=true, a request to e.g. a non-existing resource should return a 404 response code, but it returns a 500 response code. The behaviour is caused by the rendering in ResteasyNoResourceFoundView, below is a patch to fix this.

      There seems to be a problem with other response codes as well, e.g. a request with a "Accept" header that is not mapped causes a org.jboss.resteasy.spi.NotAcceptableException, but this results again in a 500 response code instead of the expected 406. I have fixed this behaviour by reconfiguring the error handling in springmvc-resteasy.xml, if interested I can supply my configuration.

      Patch for ResteasyNoResourceFoundView:

      Index: ResteasyNoResourceFoundView.java
      ===================================================================
      — ResteasyNoResourceFoundView.java (revision 839)
      +++ ResteasyNoResourceFoundView.java (working copy)
      @@ -42,7 +42,7 @@
      return null;
      }

      • };
        + }.handle(new ResteasyRequestWrapper(request), response);
        }

      @SuppressWarnings("unchecked")

      Attachments

        Activity

          People

            patriot1burke@gmail.com Bill Burke (Inactive)
            juyttenh_jira Jan Uyttenhove (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: