Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4969

ExceptionMapper not used for exception in resource setter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6.7
    • 2.6.8, 2.7.5, 3.0.0-milestone1
    • JAX-RS
    • None
    • tomee-1.6.0-SNAPSHOT

    • Unknown

    Description

      I'm trying to use the cxf extension that allows to map exceptions to reponses. The issue I have is that exceptions raised in setXX methods annontated with @PathParam for example are caught and produce an internal server error. This prevents from performing usefull parameter validation from the setter methods, where they could benefit to all services.

      Attached in a sample application that defines a custom mapper, and raises exceptions either in a setter or a service method.

      Once deployed, I do get for:

      http://localhost/testexceptions/a/b/fail_in_inject
      

      where the exception is raised at the setter level an HTTP 500 response, with entity

      <ns1:XMLFault 
          xmlns:ns1="http://cxf.apache.org/bindings/xformat">
          <ns1:faultstring 
              xmlns:ns1="http://cxf.apache.org/bindings/xformat">javax.ws.rs.WebApplicationException
          </ns1:faultstring>
      </ns1:XMLFault>
      

      and a stack in the server logs, when

      http://localhost/testexceptions/a/b/fail_in_serve
      

      where the exception is raised at service level correctly returns HTTP 400

      One sould be able to use the setter methods (or the resource constructor) to perform parameters validation, and property return errors.

      Tested with tomee 1.6.0, which ships with cxf-2.6.7

      Attachments

        1. testexceptions.war
          3 kB
          Antoine Reilles
        2. testexceptions-src.zip
          7 kB
          Antoine Reilles

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            areilles Antoine Reilles
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: