Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-9433

Unable to render view returned as Callable<String> by async servlet when running in Jetty 8

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 3.2 M1
    • Fix Version/s: 3.2 M2
    • Component/s: Web
    • Security Level: Public
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      When running the spring-mvc-async branch of the spring-mvc-showcase project in Jetty 8, the async servlet render view demo throws an exception and fails to render the view correctly.

      21:25:52 [qtp4697408-18] DispatcherServlet - DispatcherServlet with name 'appServlet' processing GET request for [/spring-mvc-showcase/views/html]
      21:25:52 [qtp4697408-18] RequestMappingHandlerMapping - Looking up handler method for path /views/html
      21:25:52 [qtp4697408-18] RequestMappingHandlerMapping - Returning handler method [public java.util.concurrent.Callable<java.lang.String> org.springframework.samples.mvc.views.ViewsController.prepare(org.springframework.ui.Model)]
      21:25:52 [qtp4697408-18] DispatcherServlet - Last-Modified value for [/spring-mvc-showcase/views/html] is: -1
      21:25:52 [qtp4697408-18] DispatcherServlet - Exiting request thread and leaving the response open
      21:25:52 [SimpleAsyncTaskExecutor-1] DispatcherServlet - Resuming asynchronous processing of GET request for [/spring-mvc-showcase/views/html]
      21:25:55 [SimpleAsyncTaskExecutor-1] DispatcherServlet - Rendering view [org.springframework.web.servlet.view.JstlView: name 'views/html'; URL [/WEB-INF/views/views/html.jsp]] in DispatcherServlet with name 'appServlet'
      21:25:55 [SimpleAsyncTaskExecutor-1] JstlView - Added model object 'fruit' of type [java.lang.String] to request in view with name 'views/html'
      21:25:55 [SimpleAsyncTaskExecutor-1] JstlView - Added model object 'foo' of type [java.lang.String] to request in view with name 'views/html'
      21:25:55 [SimpleAsyncTaskExecutor-1] DispatcherServlet - Could not complete request
      javax.servlet.ServletException: Could not get RequestDispatcher for [/WEB-INF/views/views/html.jsp]: Check that the corresponding file exists within your web application archive!
      	at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:219)
      	at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
      	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1265)
      	at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1016)
      	at org.springframework.web.servlet.DispatcherServlet.access$300(DispatcherServlet.java:141)
      	at org.springframework.web.servlet.DispatcherServlet$2.call(DispatcherServlet.java:1054)
      	at org.springframework.web.servlet.DispatcherServlet$1.call(DispatcherServlet.java:884)
      	at org.springframework.web.servlet.FrameworkServlet$1.call(FrameworkServlet.java:991)
      	at org.springframework.web.context.request.async.AsyncExecutionChainRunnable.run(AsyncExecutionChainRunnable.java:64)
      	at java.lang.Thread.run(Thread.java:722)
      21:25:55 [SimpleAsyncTaskExecutor-1] AsyncExecutionChainRunnable - Completing async request processing

      To reproduce:

      1. Checkout the spring-mvc-async branch from https://github.com/SpringSource/spring-mvc-showcase/tree/spring-mvc-async
      2. Run the web app using Jetty 8 (I'm running the latest stable build, jetty-distribution-8.1.3.v20120416)
      3. Go to http://localhost:8080/spring-mvc-showcase/#views
      4. Click on the "HTML generated by JSP template" link
      5. The above exception occurs

      The same web app works fine in Glassfish v3.

        Activity

        Hide
        kwong.lai Kwong Lai added a comment -

        If you look at org.springframework.samples.mvc.views.ViewsController, it's only the async version that returns Callable<String> that doesn't work. A non-async version that returns the same view as a string renders correctly.

        // Async version causes exception
        @RequestMapping(value = "html", method = RequestMethod.GET)
        public Callable<String> prepare(final Model model) {

        return new Callable<String>() {
        public String call() throws Exception

        { // Do some work.. Thread.sleep(3000L); model.addAttribute("foo", "bar"); model.addAttribute("fruit", "apple"); return "views/html"; }

        };
        }

        // non-async version renders correctly
        @RequestMapping(value = "html1", method = RequestMethod.GET)
        public String prepare1(final Model model)

        { model.addAttribute("foo", "bar"); model.addAttribute("fruit", "apple"); return "views/html"; }
        Show
        kwong.lai Kwong Lai added a comment - If you look at org.springframework.samples.mvc.views.ViewsController, it's only the async version that returns Callable<String> that doesn't work. A non-async version that returns the same view as a string renders correctly. // Async version causes exception @RequestMapping(value = "html", method = RequestMethod.GET) public Callable<String> prepare(final Model model) { return new Callable<String>() { public String call() throws Exception { // Do some work.. Thread.sleep(3000L); model.addAttribute("foo", "bar"); model.addAttribute("fruit", "apple"); return "views/html"; } }; } // non-async version renders correctly @RequestMapping(value = "html1", method = RequestMethod.GET) public String prepare1(final Model model) { model.addAttribute("foo", "bar"); model.addAttribute("fruit", "apple"); return "views/html"; }
        Hide
        rstoya05-aop Rossen Stoyanchev added a comment -

        This issue is now resolved. Although the programming model remains unchanged, it required some substantial internal refactoring. Thanks for reporting it!

        Show
        rstoya05-aop Rossen Stoyanchev added a comment - This issue is now resolved. Although the programming model remains unchanged, it required some substantial internal refactoring. Thanks for reporting it!

          People

          • Assignee:
            rstoya05-aop Rossen Stoyanchev
            Reporter:
            kwong.lai Kwong Lai
            Last updater:
            Rossen Stoyanchev
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              2 years, 46 weeks, 2 days ago