Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-4943

ResourceNotFoundException: Include resource path in the getMessage() method

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • API 2.9.0
    • API 2.11.0
    • API
    • None

    Description

      Currently if instantiating a ResourceNotFoundException with both a resource path and a message only the message is given out. That is e.g. a problem in DefaultGetServlet (https://github.com/apache/sling/blob/trunk/bundles/servlets/get/src/main/java/org/apache/sling/servlets/get/impl/DefaultGetServlet.java#L218).
      That leads to exceptions like this in the log

      ...
      org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:282)
      	at org.apache.sling.engine.impl.SlingRequestProcessorImpl.dispatchRequest(SlingRequestProcessorImpl.java:322)
      	at org.apache.sling.engine.impl.request.SlingRequestDispatcher.dispatch(SlingRequestDispatcher.java:216)
      	at org.apache.sling.engine.impl.request.SlingRequestDispatcher.include(SlingRequestDispatcher.java:103)
      	at 
      ... 
      Caused by: org.apache.sling.api.resource.ResourceNotFoundException: No resource found
      	at org.apache.sling.servlets.get.impl.DefaultGetServlet.doGet(DefaultGetServlet.java:219)
      	at org.apache.sling.api.servlets.SlingSafeMethodsServlet.mayService(SlingSafeMethodsServlet.java:269)
      	at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:345)
      	at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:376)
      	at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:533)
      	at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:44)
      	at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:77)
      	at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68)
      ...
      

      You basically have no clue which resource path was requested (especially if the request was issued through request dispatching. Therefore I propose to always include the resource path in the message given out by getMessage() or getLocalizedMessage()

      Attachments

        Activity

          People

            Unassigned Unassigned
            kwin Konrad Windszus
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: