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

org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper does not print the WebApplicationException stack trace even when log level is set to FINEST

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3.7, 2.4.3
    • 2.4.4, 2.3.8
    • JAX-RS
    • Windows 7 64-bit, JDK 1.7.0

    • Novice

    Description

      WebApplicationException occurring as a result of a JAXB mapping (an internal NullPointerException caused it), never got printed on the console or in the logs. The following message did get printed:

      WARNING WebApplicationException has been caught, cause: java.lang.NullPointerException

      But beyond this, no other information was available. Debugging revealed that the problem was in JAXB mapping in one of my classes, but it would have been very helpful if the exception trace is printed in the logs or on the console.

      The problem remained even after setting the log levels in logging.properties to FINEST. Other FINEST logs did get printed fine, except for the stack trace of the exception. My research showed that the setPrintStackTrace(boolean) method of WebApplicationExceptionMapper never gets called from anywhere. This will mean that the printStackTrace variable of the class always remains false, resulting in eternal shadowing of the stack trace.

      I made a small change to my local copy of org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper Java file and patched it to cxf-2.4.3.jar to get the stack trace in my logs when log level was set to INFO or lower. The three line change is as below:

      public Response toResponse(WebApplicationException ex) {
      + if(LOG.isLoggable(Level.INFO))

      { + printStackTrace = true; + }

      ...
      (lines with + are added lines)

      It would be great if you can make this change in subsequent versions.

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            dearjadu Kartik Pandya
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified