• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Struts 2 InterceptorStack Issues

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok - I'm having a bad start to the day and this is driving me nuts. I'm using the Convention plugin, and below I've attached a copy of my struts.xml. As you can see I've got two custom interceptors which I'm adding to a copy of the param-prepare-param stack.

Through logging I can see that my two custome interceptors are being initialized (their constructors are being called) but thereafter neither of the interceptors intercept() method is being invoked.

Using the config-browser plugin I see that my custom interceptors are *not* in the stack for the default, admin or diagnostic namespaces. Further none of the namespaces are using the param-prepare-param stack the first Parameter interceptor is missing as well. It looks like I'm using the bog-standard struts-default stack.

What on arth have I missed?

Regards

<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="true" />
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory" />

<package name="default" extends="struts-default">
<interceptors>
<interceptor name="redirectMessage" class="com.blackbox.genesis.interceptors.RedirectMessageInterceptor"/>
<interceptor name="connectionStoreMonitor" class="com.blackbox.genesis.interceptors.ConnectionStoreMonitorInterceptor"/>
<interceptor-stack name="secureStack">
<interceptor-ref name="redirectMessage"/>
<interceptor-ref name="exception"/>
<interceptor-ref name="connectionStoreMonitor"/>
<interceptor-ref name="alias"/>
<interceptor-ref name="params"/>
<interceptor-ref name="servletConfig"/>
<interceptor-ref name="i18n"/>
<interceptor-ref name="prepare"/>
<interceptor-ref name="chain"/>
<interceptor-ref name="debugging"/>
<interceptor-ref name="scopedModelDriven"/>
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="fileUpload"/>
<interceptor-ref name="checkbox"/>
<interceptor-ref name="multiselect"/>
<interceptor-ref name="staticParams"/>
<interceptor-ref name="actionMappingParams"/>
<interceptor-ref name="params">
<param name="excludeParams">dojo\..*,^struts\..*</param>
</interceptor-ref>
<interceptor-ref name="conversionError"/>
<interceptor-ref name="validation">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
<interceptor-ref name="workflow">
<param name="excludeMethods">input,back,cancel,browse</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>


<default-interceptor-ref name="secureStack"/>


</package>

<!-- Add packages here -->
<package name="admin" namespace="/admin" extends="default"/>
<package name="diagnostics" extends="default"/>
</struts>
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you setting the parent package constant or otherwise telling the Convention plugin what package to use (or interceptors) in your "conventional" and/or annotated actions?
 
Glen Divers
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Are you setting the parent package constant or otherwise telling the Convention plugin what package to use (or interceptors) in your "conventional" and/or annotated actions?



Hi Dave

No, I wasn't - I've added the @ParentPackage annotation to my actions and now, most of them are picking up the correct stack. The ones that aren't picking up the correct stack are those that are using JSON results. For those to work you have to specify @ParentPackage(value="json-default") which extends struts-default, so those actions are not using the correct interceptor stack. I'll try adding the @Interceptor annotation to those, but it all seems to be getting a bit kludgy.

Regards
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the only thing the json package does is declare result types why not just extend that in your package? (I don't recall what else it does--if it does more, just duplicate it.)

Still, it seems easier to set the constant rather than annotate each action.
 
reply
    Bookmark Topic Watch Topic
  • New Topic