Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4199

Exclusion of URLs should be done before calling prepare.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.16
    • Component/s: Dispatch Filter
    • Labels:
      None

      Description

      I have some webservices under /services in my webapp, and I have excluded them from Struts by using the excludePattern filter:

      <param-name>struts.action.excludePattern</param-name>
      <param-value>/services/.*</param-value>
      

      The problem is that the classes StrutsPrepareAndExecuteFilter and StrutsPrepareFilter do some calls before to prepare before checking if the URL should be treated. In the case of the webservices it provokes the following exception:

      ####<Sep 13, 2013 6:38:54 PM EDT> <Error> <HTTP> <naboo.mia.usa.sinvest> <EcoPrdInt> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1379111934567> <BEA-101108> <[weblogic.servlet.internal.WebAppServletContext@2f97ff - appName: 'test-int', name: 'test-int.war', context-path: '/test-int', spec-version: '2.5'] Unsupported encoding: "UTF-8; action="urn:publishDocumentForSignature"" specified.
      java.io.UnsupportedEncodingException: Unsupported Encoding UTF-8; action="urn:publishDocumentForSignature"
              at weblogic.servlet.internal.ServletRequestImpl.setCharacterEncoding(ServletRequestImpl.java:428)
              at weblogic.servlet.internal.ServletRequestImpl.initRequestEncoding(ServletRequestImpl.java:1115)
              at weblogic.servlet.internal.ServletRequestImpl.getCharacterEncoding(ServletRequestImpl.java:451)
              at org.apache.struts2.dispatcher.Dispatcher.applyEncoding(Dispatcher.java:762)
              at org.apache.struts2.dispatcher.Dispatcher.prepare(Dispatcher.java:748)
              at org.apache.struts2.dispatcher.ng.PrepareOperations.setEncodingAndLocale(PrepareOperations.java:121)
              at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:85)
      

      And that's due to the filter calling prepare to set the encoding and locale in the following code in StrutsPrepareAndExecuteFilter:

      [...]
              try {
                  prepare.setEncodingAndLocale(request, response);
                  prepare.createActionContext(request, response);
                  prepare.assignDispatcherToThread();
                  if (excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) {
                      chain.doFilter(request, response);
                  } else {
      [...]
      

      But if the URL is going to be excluded, why is it doing that call? I think the calls to prepare should be done after checking the URL for exclusions. Unless I'm missing something, it shouldn't impact anything, right?

      Thanks

      JL

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jogep Johannes Geppert
                Reporter:
                jlmagc Jose L Martinez-Avial
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: