DynamicMappingFilter и многим вложенным запросам с ошибочными страницами - PullRequest
0 голосов
/ 20 февраля 2012

Я настроил Stripes с помощью DynamicMappingFilter, чтобы я мог использовать URL без "* .action". Я хочу, чтобы Полосы обработали мои страницы ошибок. Я сделал простую страницу error.jsp, на которую ссылался в web.xml для обработки 404 ошибок:

<jsp:forward page="/support/Error" />

Переадресация на это, теперь почти пустое, действие Stripes:

public class ErrorAction extends BaseAction implements ActionBean {

    @DefaultHandler
    public Resolution action() {
        return new ForwardResolution("/WEB-INF/pages/test.jsp");
    }
}

/WEB-INF/pages/test.jsp - это обычная HTML-страница Hello World (сгенерированная Netbeans).

Но по какой-то причине это не работает. После пересылки на /WEB-INF/pages/test.jsp ErrorAction запрашивается снова, и этот цикл продолжается до тех пор, пока GlassFish не остановит его.

Вот что регистрируется (/fasdfasdfasdf - это URL, который не существует):

INFO: 14:37:13,646 TRACE StripesFilter:198 - Intercepting request to URL: /fasdfasdfasdf
INFO: 14:37:13,648 DEBUG UrlBindingFactory:187 - No URL binding matches /fasdfasdfasdf
INFO: 14:37:13,648 DEBUG UrlBindingFactory:187 - No URL binding matches /fasdfasdfasdf

INFO: 14:37:13,650 TRACE StripesFilter:198 - Intercepting request to URL: /support/Error
WARNING: PWC4011: Unable to set request character encoding to UTF-8 from context /mycompany-web-seller, because request parameters have already been read, or ServletRequest.getReader() has already been called
INFO: 14:37:13,652 DEBUG UrlBindingFactory:187 - Matched /support/Error to /support/Error
INFO: 14:37:13,653 DEBUG UrlBindingFactory:187 - Matched /support/Error to /support/Error
INFO: 14:37:13,653 TRACE DispatcherServlet:198 - Dispatching request to URL: /support/Error
INFO: 14:37:13,654 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage RequestInit
INFO: 14:37:13,654 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage ActionBeanResolution
INFO: 14:37:13,654 DEBUG UrlBindingFactory:187 - Matched /support/Error to /support/Error
INFO: 14:37:13,655 DEBUG UrlBindingFactory:187 - Matched /support/Error to /support/Error
INFO: 14:37:13,656 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage HandlerResolution
INFO: 14:37:13,656 DEBUG UrlBindingFactory:187 - Matched /support/Error to /support/Error
INFO: 14:37:13,657 DEBUG DispatcherHelper:187 - Resolved event: action; will invoke: ErrorAction.action()
INFO: 14:37:13,657 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage BindingAndValidation
INFO: 14:37:13,658 DEBUG DefaultActionBeanPropertyBinder:187 - Running required field validation on bean class com.mycompany.stripes.support.ErrorAction
INFO: 14:37:13,658 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage CustomValidation
INFO: 14:37:13,659 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage EventHandling
INFO: 14:37:13,659 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage ResolutionExecution
INFO: 14:37:13,660 DEBUG HttpCacheInterceptor:187 - Looking for HttpCache on com.mycompany.stripes.support.ErrorAction.action()
INFO: 14:37:13,660 DEBUG UrlBindingFactory:187 - No URL binding matches /WEB-INF/pages/test.jsp
INFO: 14:37:13,661 DEBUG UrlBindingFactory:187 - No URL binding matches /WEB-INF/pages/test.jsp
INFO: 14:37:13,662 TRACE ForwardResolution:198 - Forwarding to URL: /WEB-INF/pages/test.jsp

INFO: 14:37:13,667 TRACE StripesFilter:198 - Intercepting request to URL: /support/Error
INFO: 14:37:13,668 DEBUG UrlBindingFactory:187 - Matched /support/Error to /support/Error
INFO: 14:37:13,669 DEBUG UrlBindingFactory:187 - Matched /support/Error to /support/Error
INFO: 14:37:13,670 TRACE DispatcherServlet:198 - Dispatching request to URL: /support/Error
INFO: 14:37:13,670 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage RequestInit
INFO: 14:37:13,671 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage ActionBeanResolution
INFO: 14:37:13,671 DEBUG UrlBindingFactory:187 - Matched /support/Error to /support/Error
INFO: 14:37:13,672 DEBUG UrlBindingFactory:187 - Matched /support/Error to /support/Error
INFO: 14:37:13,673 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage HandlerResolution
INFO: 14:37:13,673 DEBUG UrlBindingFactory:187 - Matched /support/Error to /support/Error
INFO: 14:37:13,674 DEBUG DispatcherHelper:187 - Resolved event: action; will invoke: ErrorAction.action()
INFO: 14:37:13,675 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage BindingAndValidation
INFO: 14:37:13,675 DEBUG DefaultActionBeanPropertyBinder:187 - Running required field validation on bean class com.mycompany.stripes.support.ErrorAction
INFO: 14:37:13,676 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage CustomValidation
INFO: 14:37:13,676 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage EventHandling
INFO: 14:37:13,677 DEBUG ExecutionContext:187 - Transitioning to lifecycle stage ResolutionExecution
INFO: 14:37:13,677 DEBUG HttpCacheInterceptor:187 - Looking for HttpCache on com.mycompany.stripes.support.ErrorAction.action()
INFO: 14:37:13,678 DEBUG UrlBindingFactory:187 - No URL binding matches /WEB-INF/pages/test.jsp
INFO: 14:37:13,679 DEBUG UrlBindingFactory:187 - No URL binding matches /WEB-INF/pages/test.jsp
INFO: 14:37:13,679 TRACE ForwardResolution:198 - Forwarding to URL: /WEB-INF/pages/test.jsp

... and again the same

И исключение:

WARNING: ApplicationDispatcher[/mycompany-web-seller] PWC1231: Servlet.service() for servlet default threw exception 
javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20                    
  at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:772)                         
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)                           
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483)                   
  at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)                       
  at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)                         

  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)                          
  at net.sourceforge.stripes.action.ForwardResolution.execute(ForwardResolution.java:110)                            
  at net.sourceforge.stripes.controller.DispatcherHelper$7.intercept(DispatcherHelper.java:508)                      
  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)                          
  at net.sourceforge.stripes.controller.HttpCacheInterceptor.intercept(HttpCacheInterceptor.java:99)                 
  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)                          
  at net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)                          
  at net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)                              
  at net.sourceforge.stripes.controller.DispatcherHelper.executeResolution(DispatcherHelper.java:502)                
  at net.sourceforge.stripes.controller.DispatcherServlet.executeResolution(DispatcherServlet.java:286)              
  at net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:170)                        
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)                                                    
  at net.sourceforge.stripes.controller.DynamicMappingFilter$2.doFilter(DynamicMappingFilter.java:431)               
  at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247)                               
  at net.sourceforge.stripes.controller.DynamicMappingFilter.doFilter(DynamicMappingFilter.java:418)                 
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)               
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)                       
  at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:785)                         
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)                           
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483)                   
  at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)                       
  at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)                         
  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)                          
  at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:785)                                     
  at org.apache.jsp.error_jsp._jspService(error_jsp.java:48)                                                         
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)                                             
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)                                                    
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)                                 
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)                                        
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)                                               
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)                                                    
  at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)                                     
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)               
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)                       
  at net.sourceforge.stripes.controller.DynamicMappingFilter.doFilter(DynamicMappingFilter.java:397)                 
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)               
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)                       
  at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:785)                         
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)                           
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)                   
  at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)                       
  at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)                         
  at org.apache.catalina.core.ApplicationDispatcherForward.custom(ApplicationDispatcherForward.java:253)             
  at org.apache.catalina.core.ApplicationDispatcherForward.status(ApplicationDispatcherForward.java:209)             
  at org.apache.catalina.core.ApplicationDispatcherForward.commit(ApplicationDispatcherForward.java:131)             
  at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:353)                         

  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)                          
  at net.sourceforge.stripes.action.ForwardResolution.execute(ForwardResolution.java:110)                            
  at net.sourceforge.stripes.controller.DispatcherHelper$7.intercept(DispatcherHelper.java:508)                      
  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)                          
  at net.sourceforge.stripes.controller.HttpCacheInterceptor.intercept(HttpCacheInterceptor.java:99)                 
  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)                          
  at net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
  at net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)                          
  at net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)                              
  at net.sourceforge.stripes.controller.DispatcherHelper.executeResolution(DispatcherHelper.java:502)                
  at net.sourceforge.stripes.controller.DispatcherServlet.executeResolution(DispatcherServlet.java:286)              
  at net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:170)                        
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)                                                    
  at net.sourceforge.stripes.controller.DynamicMappingFilter$2.doFilter(DynamicMappingFilter.java:431)               
  at net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247)                               
  at net.sourceforge.stripes.controller.DynamicMappingFilter.doFilter(DynamicMappingFilter.java:418)                 
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)               
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)                       
  at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:785)                         
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)                           
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483)                   
  at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)                       
  at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)                         
  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)                          
  at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:785)                                     
  at org.apache.jsp.error_jsp._jspService(error_jsp.java:48)                                                         
  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)                                             
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)                                                    
  at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)                                 
  at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)                                        
  at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)                                               
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)                                                    
  at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)                                     
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)               
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)                       
  at net.sourceforge.stripes.controller.DynamicMappingFilter.doFilter(DynamicMappingFilter.java:397)                 
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)               
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)                       
  at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:785)                         
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)                           
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)                   
  at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)                       
  at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)                         
  at org.apache.catalina.core.ApplicationDispatcherForward.custom(ApplicationDispatcherForward.java:253)             
  at org.apache.catalina.core.ApplicationDispatcherForward.status(ApplicationDispatcherForward.java:209)             
  at org.apache.catalina.core.ApplicationDispatcherForward.commit(ApplicationDispatcherForward.java:131)             
  at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:353)          
  ... and again the same

Вот как выполняется запрос при трассировке в отладчике (важны только части:

-> /badurl
   -> DynamicMappingFilter
      -> chain.doFilter
      <- 404
      * no Stripes ActionBean found for /badurl
   <-
-> error.jsp
   -> DynamicMappingFilter
      -> chain.doFilter
         -> error.jsp
            -> /support/Error
               -> DynamicMappingFilter
                  -> chain.doFilter
                  <- 404
                  * ErrorAction found
                  -> stripesDispatcher.service
                     -> ForwardResolution.execute (/WEB-INF/pages/test.jsp)
                        -> DynamicMappingFilter
                           -> chain.doFilter
                              -> /WEB-INF/pages/test.jsp
                              <-
                           <- OK
                        <-
                        ? it does not return to ForwardResolution.execute
                        -> DynamicMappingFilter
                           -> chain.doFilter
                              -> error.jsp
                               and the loop starts again

Кто-нибудь знает, почему после пересылки на test.jsp появляются запросы на /error.jsp? Запрос /error.jsp, /support/Error работает как положено - /WEB-INF/pages/test.jsp отображается и запрос завершается.

РЕДАКТИРОВАТЬ: Если error.jsp переходит прямо к /WEB-INF/pages/test, то не будет никакого цикла. Это просто когда он проходит через действие Stripes, когда это происходит.

1 Ответ

0 голосов
/ 21 февраля 2012

Я думаю, что ваш "/WEB-INF/pages/test.jsp" не существует по этому URL, это вызывает ошибку 404, которая запускает все заново, вызывая бесконечный цикл.

Можете ли вы получить доступ к странице "/WEB-INF/pages/test.jsp" напрямую без каких-либо проблем?

...