aspose file tools*
The moose likes Struts and the fly likes Struts 2 InterceptorStack Issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 InterceptorStack Issues" Watch "Struts 2 InterceptorStack Issues" New topic
Author

Struts 2 InterceptorStack Issues

Glen Divers
Ranch Hand

Joined: Jan 21, 2010
Posts: 61
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>
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jan 21, 2010
Posts: 61
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2 InterceptorStack Issues