title: Struts 2 interceptor firing when it shouldn't
body: <p>I have different areas in my webapp, basically:</p>
  <ol>
  <li>Login actions. No special interceptor needs.</li>
  <li>Secure zone. Only for authenticated users. AuthenticationInterceptor redirects non authenticated users to logout action.</li>
  <li>Admin zone. Only for admin users. AdministrationInterceptor redirects non admin users to logout action.</li>
  </ol>
  <p>Hence, I have divided my actions in packages.</p>
  <ul>
  <li><code>numeritos-default</code> is a package with no actions, just to define the
  interceptors and a couple stacks, in order to inherit from it.</li>
  <li><code>numeritos-login</code> is a package that inherits directly from
  struts-default and, hence, uses the defaultStack from struts.</li>
  <li><code>numeritos-secure</code> inherits from numeritos-default and SHOULD (afaik)
  use the numeritos-default default stack.</li>
  <li><code>numeritos-admin</code> inherits
  from numeritos-default but defines a different default stack, in
  order to add the administrationInterceptor to the default stack.</li>
  </ul>
  <p>The thing is, <strong>the actions in numeritos-secure are executing the administrationInterceptor</strong> when they shouldn't, since their default stack, inherited from numeritos-default doesn't include that interceptor (I can't figure out the reason), hence only admin users can access the application. The rest of users are kicked out of the whole secure zone, when they should be only kicked out of the admin zone.</p>
  <p>I have the following struts.xml configuration file. Sorry to post the whole of it, but I think it could help. All classes references are really Spring beans names, since all dependencies are managed by Spring.</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!DOCTYPE struts PUBLIC
      &quot;-//Apache Software Foundation//DTD Struts Configuration 2.5//EN&quot;
      &quot;http://struts.apache.org/dtds/struts-2.5.dtd&quot;&gt;
  
  &lt;struts&gt;
  
      &lt;constant name=&quot;struts.custom.i18n.resources&quot; value=&quot;global-messages&quot; /&gt;
      
      &lt;constant name=&quot;struts.devMode&quot; value=&quot;true&quot; /&gt;
      
      &lt;constant name=&quot;struts.ui.theme&quot; value=&quot;simple&quot; /&gt;
      
      &lt;package name=&quot;numeritos-default&quot; extends=&quot;struts-default&quot;&gt;
          &lt;interceptors&gt;
          
              &lt;!-- Session authentication interceptor --&gt;
              &lt;interceptor name=&quot;authenticationInterceptor&quot; class=&quot;authenticationInterceptor&quot;/&gt;
  
              &lt;!-- Administration privileges interceptor --&gt;
              &lt;interceptor name=&quot;administrationInterceptor&quot; class=&quot;administrationInterceptor&quot;/&gt;  
              
              &lt;!-- Caching headers interceptor --&gt;
              &lt;interceptor name=&quot;cachingHeadersInterceptor&quot; class=&quot;cachingHeadersInterceptor&quot;/&gt;
          
              &lt;!-- Default interceptor stack for this package (default + authentication) --&gt;  
              &lt;interceptor-stack name=&quot;numeritosDefaultStack&quot;&gt;
                  &lt;interceptor-ref name=&quot;authenticationInterceptor&quot;/&gt;
                  &lt;interceptor-ref name=&quot;cachingHeadersInterceptor&quot;/&gt;             
                  &lt;interceptor-ref name=&quot;defaultStack&quot;/&gt;
              &lt;/interceptor-stack&gt;
              
              &lt;!-- Default interceptor stack for administration packages (default + administration) --&gt;   
              &lt;interceptor-stack name=&quot;numeritosAdminStack&quot;&gt;
                  &lt;interceptor-ref name=&quot;administrationInterceptor&quot;/&gt;
                  &lt;interceptor-ref name=&quot;numeritosDefaultStack&quot;/&gt;
              &lt;/interceptor-stack&gt;            
                      
          &lt;/interceptors&gt;
          
          &lt;!-- Secure interceptor stack as default --&gt;
          &lt;default-interceptor-ref name=&quot;numeritosDefaultStack&quot;/&gt;
                  
      &lt;/package&gt;
  
      &lt;package name=&quot;numeritos-login&quot; extends=&quot;struts-default&quot;&gt;
          
          
          &lt;action name=&quot;welcome&quot; class=&quot;welcomeAction&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;freemarker&quot;&gt;ftl/login.ftl&lt;/result&gt;
          &lt;/action&gt;
      
          &lt;action name=&quot;login&quot; class=&quot;loginAction&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;redirectAction&quot;&gt;exerciseLoad&lt;/result&gt;
              &lt;result name=&quot;input&quot; type=&quot;freemarker&quot;&gt;ftl/login.ftl&lt;/result&gt;
          &lt;/action&gt;
          
      &lt;/package&gt;
      
      &lt;package name=&quot;numeritos-secure&quot; extends=&quot;numeritos-default&quot;&gt;
          
          &lt;!-- Common login result --&gt;        
          &lt;global-results&gt;
               &lt;result name=&quot;login&quot; type=&quot;redirectAction&quot;&gt;logout&lt;/result&gt;
          &lt;/global-results&gt;
          
          &lt;action name=&quot;exerciseLoad&quot; class=&quot;exerciseLoadAction&quot;&gt;
              &lt;result name=&quot;simple_op&quot; type=&quot;freemarker&quot;&gt;ftl/simple_operation_view.ftl&lt;/result&gt;
              &lt;result name=&quot;equation&quot; type=&quot;freemarker&quot;&gt;ftl/equation_view.ftl&lt;/result&gt;
          &lt;/action&gt;
          
          &lt;action name=&quot;exerciseCheck&quot; class=&quot;exerciseCheckAction&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;freemarker&quot;&gt;ftl/show_exercise_result.ftl&lt;/result&gt;
              &lt;result name=&quot;input&quot; type=&quot;freemarker&quot;&gt;ftl/answer_format_error.ftl&lt;/result&gt;
          &lt;/action&gt;
          
          &lt;action name=&quot;stats&quot; class=&quot;statsAction&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;freemarker&quot;&gt;ftl/stats.ftl&lt;/result&gt;
          &lt;/action&gt;
          
          &lt;action name=&quot;modulesList&quot; class=&quot;modulesListAction&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;freemarker&quot;&gt;ftl/modules_list.ftl&lt;/result&gt;
          &lt;/action&gt;
          
          &lt;action name=&quot;selectModule&quot; class=&quot;selectModuleAction&quot;&gt;
              &lt;result name=&quot;input&quot; type=&quot;freemarker&quot;&gt;ftl/modules_list.ftl&lt;/result&gt;
              &lt;result name=&quot;success&quot; type=&quot;redirectAction&quot;&gt;exerciseLoad&lt;/result&gt;
          &lt;/action&gt;        
          
          &lt;action name=&quot;userSettings&quot; class=&quot;userSettingsAction&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;freemarker&quot;&gt;ftl/user_settings.ftl&lt;/result&gt;
          &lt;/action&gt;
          
          &lt;action name=&quot;changePassword&quot; class=&quot;changePasswordAction&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;freemarker&quot;&gt;ftl/user_settings.ftl&lt;/result&gt;
              &lt;result name=&quot;input&quot; type=&quot;freemarker&quot;&gt;ftl/user_settings.ftl&lt;/result&gt;
          &lt;/action&gt;
          
          &lt;action name=&quot;logout&quot; class=&quot;logoutAction&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;freemarker&quot;&gt;ftl/login.ftl&lt;/result&gt;        
          &lt;/action&gt;        
            
      &lt;/package&gt;
      
      &lt;package name=&quot;numeritos-admin&quot; extends=&quot;numeritos-secure&quot;&gt;
      
          &lt;!-- Admin interceptor stack as default --&gt;
          &lt;default-interceptor-ref name=&quot;numeritosAdminStack&quot;/&gt;
          
          &lt;!-- Common login result --&gt;        
          &lt;global-results&gt;
               &lt;result name=&quot;login&quot; type=&quot;redirectAction&quot;&gt;logout&lt;/result&gt;
          &lt;/global-results&gt;
          
          &lt;action name=&quot;adminConsole&quot; class=&quot;adminConsoleAction&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;freemarker&quot;&gt;ftl/admin_console_results.ftl&lt;/result&gt;
          &lt;/action&gt;   
          
          &lt;action name=&quot;adminConsoleGroups&quot; class=&quot;adminConsoleGroupsAction&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;freemarker&quot;&gt;ftl/admin_console_groups.ftl&lt;/result&gt;
          &lt;/action&gt;
          
          &lt;action name=&quot;adminCreateGroup&quot; class=&quot;adminConsoleGroupsAction&quot; method=&quot;create&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;redirectAction&quot;&gt;adminConsoleGroups&lt;/result&gt;
          &lt;/action&gt; 
          
          &lt;action name=&quot;adminDeleteGroup&quot; class=&quot;adminConsoleGroupsAction&quot; method=&quot;delete&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;redirectAction&quot;&gt;adminConsoleGroups&lt;/result&gt;
          &lt;/action&gt;        
                
      &lt;/package&gt;
      
      &lt;package name=&quot;json-admin&quot; extends=&quot;numeritos-default, json-default&quot;&gt;
          &lt;interceptors&gt;
              &lt;!-- Default interceptor stack for this package (default + administration + json) --&gt;   
              &lt;interceptor-stack name=&quot;numeritosJsonAdminStack&quot;&gt;
                  &lt;interceptor-ref name=&quot;administrationInterceptor&quot;/&gt;
                  &lt;interceptor-ref name=&quot;json&quot;/&gt;
                  &lt;interceptor-ref name=&quot;numeritosDefaultStack&quot;/&gt;
              &lt;/interceptor-stack&gt;        
          &lt;/interceptors&gt;
          
          &lt;default-interceptor-ref name=&quot;numeritosJsonAdminStack&quot;/&gt;     
                  
          &lt;action name=&quot;jsonTest&quot; class=&quot;jsonTestAction&quot;&gt;
              &lt;result name=&quot;success&quot; type=&quot;json&quot;&gt;
                  &lt;param name=&quot;root&quot;&gt;users&lt;/param&gt;
              &lt;/result&gt;
          &lt;/action&gt;       
      &lt;/package&gt; 
      
  &lt;/struts&gt;
  </code></pre>