Struts 2
  1. Struts 2
  2. WW-2673

Returns 500 for a non-existent resource, should return 404

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Not A Problem
    • Affects Version/s: 2.1.2
    • Fix Version/s: None
    • Component/s: Plugin - REST
    • Labels:
      None
    • Environment:

      WAS 6.1 on WinXP64

    • Flags:
      Important

      Description

      When I request an existing object via the REST plugin it is returned ok. However, requesting a non-existent resource should return a 404 (page not found) to be truly REST-ful. What I get instead is a 500 error and this not very helpful stack trace:

      [9/06/08 09:32:00:553 NZST] 0000001f WebApp E [Servlet Error]-[<null>]: com.ibm.ws.webcontainer.webapp.WebAppErrorReport:
      at com.ibm.ws.webcontainer.webapp.WebAppDispatcherContext.sendError(WebAppDispatcherContext.java:538)
      at com.ibm.ws.webcontainer.srt.SRTServletResponse.sendError(SRTServletResponse.java:967)
      at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:725)
      at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
      at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:467)
      at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
      at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:768)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:676)
      at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:691)
      at com.ibm.ws.wswebcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:118)
      at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.invokeFilters(DefaultExtensionProcessor.java:791)
      at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:741)
      at com.ibm.ws.wswebcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:113)
      at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3276)
      at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
      at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
      at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1455)
      at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:113)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:454)
      at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:383)
      at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
      at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
      at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
      at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
      at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
      at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:195)
      at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:743)
      at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:873)
      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)

      The problem seems to be that nothing goes on to the valuestack (correctly since the resource doesn't exist) but whatever is trying to read from the valuestack barfs because it's empty.

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        3d 22h 11m 1 Michael Watson 12/Jun/08 20:46
        In Progress In Progress Open Open
        4s 1 Michael Watson 12/Jun/08 20:46
        Open Open Resolved Resolved
        7h 10m 1 Don Brown 13/Jun/08 03:57
        Resolved Resolved Closed Closed
        1598d 19h 16m 1 Lukasz Lenart 28/Oct/12 22:13
        Lukasz Lenart made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Jeff Turner made changes -
        Project Import Mon Feb 01 01:17:42 UTC 2010 [ 1264987062082 ]
        Antonio Petrelli made changes -
        Workflow Struts - editable closed status (temporary) [ 46966 ] Struts - editable closed status [ 52458 ]
        Antonio Petrelli made changes -
        Workflow Struts - editable closed status [ 45183 ] Struts - editable closed status (temporary) [ 46966 ]
        Don Brown made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.1.3 [ 21864 ]
        Resolution Not A Problem [ 7 ]
        Hide
        Michael Watson added a comment -

        Because I'd mis-configured it. I now have it working by having a get method like this, and no longer get a 500:
        public HttpHeaders fetch()
        {
        DefaultHttpHeaders result = new DefaultHttpHeaders("fetch");
        if (null == model)

        { result.withStatus(HttpServletResponse.SC_NOT_FOUND); }

        return result;
        }

        Show
        Michael Watson added a comment - Because I'd mis-configured it. I now have it working by having a get method like this, and no longer get a 500: public HttpHeaders fetch() { DefaultHttpHeaders result = new DefaultHttpHeaders("fetch"); if (null == model) { result.withStatus(HttpServletResponse.SC_NOT_FOUND); } return result; }
        Don Brown made changes -
        Fix Version/s 2.1.3 [ 21864 ]
        Hide
        Don Brown added a comment -

        Why withdrawn?

        Show
        Don Brown added a comment - Why withdrawn?
        Michael Watson made changes -
        Assignee Michael Watson [ bigmikew ]
        Michael Watson made changes -
        Priority Blocker [ 1 ] Trivial [ 5 ]
        Hide
        Michael Watson added a comment -

        withdrawn

        Show
        Michael Watson added a comment - withdrawn
        Michael Watson made changes -
        Status In Progress [ 3 ] Open [ 1 ]
        Michael Watson made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Michael Watson made changes -
        Field Original Value New Value
        Assignee Michael Watson [ bigmikew ]
        Michael Watson created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Michael Watson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development