Uploaded image for project: 'Crowd Data Center'
  1. Crowd Data Center
  2. CWD-4770

Trying to use a plugin using spring-mvc might fail with a classcast exception

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • None
    • 2.9.1, 2.10.1
    • None

    Description

      Trying to use a plugin that uses spring-mvc might cause the following exception:

      [INFO] [talledLocalContainer] java.lang.ClassCastException: org.springframework.web.context.request.async.WebAsyncManager cannot be cast to org.springframework.web.context.request.async.WebAsyncManager
      [INFO] [talledLocalContainer]   at org.springframework.web.context.request.async.WebAsyncUtils.getAsyncManager(WebAsyncUtils.java:46)
      [INFO] [talledLocalContainer]   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:960)
      [INFO] [talledLocalContainer]   at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
      
      

      This is due to spring-mvc setting a request attribute with the WebAsyncManager in core (using Spring3), and spring request processing in the plugin trying to reuse it and cast it to the Spring4 version, which fails.

      A workaround is to declare a servlet-filter module in the plugin that will handle cleaning the request attribute before further processing:

          @Override
          public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
              if (request.getAttribute(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE) != null) {
                  request.setAttribute(WebAsyncUtils.WEB_ASYNC_MANAGER_ATTRIBUTE, null);
              }
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            lpater Lukasz Pater
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: