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

        Hide
        Michael Watson added a comment -

        withdrawn

        Show
        Michael Watson added a comment - withdrawn
        Hide
        Don Brown added a comment -

        Why withdrawn?

        Show
        Don Brown added a comment - Why withdrawn?
        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; }

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development