You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Gamble, Wesley (WG10)" <WG...@tmw.com> on 2008/06/10 20:21:36 UTC
Custom interceptor not firing
All,
I set up a custom interceptor, but it is not being invoked.
As far as I can tell from looking at _Struts 2 in Action_, I constructed
my class correctly. It is named "CompanyIdentificationInterceptor".
My struts.xml file now has this configuration in it to accommodate this
new interceptor:
<interceptors>
<interceptor name="companyInterceptor"
class="com.tmw.applicant.tracking.interceptors.CompanyIdentificationInte
rceptor" />
<interceptor-stack name="customStack">
<interceptor-ref name="companyInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="customStack" />
Have I missed something?
Thanks,
Wes
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Custom interceptor not firing
Posted by "Gamble, Wesley (WG10)" <WG...@tmw.com>.
I am using Annotation-based actions. I am starting to suspect that they
are not hooked up to the interceptor stack by default. Is that right?
Is there some annotation that I can use to get interceptors to fire?
-----Original Message-----
From: Lukasz Lenart [mailto:lukasz.lenart@googlemail.com]
Sent: Tuesday, June 10, 2008 2:00 PM
To: Struts Users Mailing List
Cc: newton.dave@yahoo.com
Subject: Re: Custom interceptor not firing
Hi,
2008/6/10 Gamble, Wesley (WG10) <WG...@tmw.com>:
> As far as I can tell from looking at _Struts 2 in Action_, I
constructed
> my class correctly. It is named "CompanyIdentificationInterceptor".
>
The name is not important, did you implement
com.opensymphony.xwork2.interceptor.Interceptor interface or extend
com.opensymphony.xwork2.interceptor.AbstractInterceptor?
Regards
--
Lukasz
http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Custom interceptor not firing
Posted by "Gamble, Wesley (WG10)" <WG...@tmw.com>.
I started out implementing the interface and then when I couldn't get it
to work, I also extended the abstract class.
I assume that the interceptor needs a default constructor as well?
Wes
-----Original Message-----
From: Lukasz Lenart [mailto:lukasz.lenart@googlemail.com]
Sent: Tuesday, June 10, 2008 2:00 PM
To: Struts Users Mailing List
Cc: newton.dave@yahoo.com
Subject: Re: Custom interceptor not firing
Hi,
2008/6/10 Gamble, Wesley (WG10) <WG...@tmw.com>:
> As far as I can tell from looking at _Struts 2 in Action_, I
constructed
> my class correctly. It is named "CompanyIdentificationInterceptor".
>
The name is not important, did you implement
com.opensymphony.xwork2.interceptor.Interceptor interface or extend
com.opensymphony.xwork2.interceptor.AbstractInterceptor?
Regards
--
Lukasz
http://www.lenart.org.pl/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Custom interceptor not firing
Posted by Lukasz Lenart <lu...@googlemail.com>.
Hi,
2008/6/10 Gamble, Wesley (WG10) <WG...@tmw.com>:
> As far as I can tell from looking at _Struts 2 in Action_, I constructed
> my class correctly. It is named "CompanyIdentificationInterceptor".
>
The name is not important, did you implement
com.opensymphony.xwork2.interceptor.Interceptor interface or extend
com.opensymphony.xwork2.interceptor.AbstractInterceptor?
Regards
--
Lukasz
http://www.lenart.org.pl/
RE: Custom interceptor not firing - ANSWER
Posted by "Gamble, Wesley (WG10)" <WG...@tmw.com>.
So the answer to my problem was that I was using Annotation based
actions, and these do not pick up a custom interceptor-stack by default,
unless you place the @ParentPackage annotation on _each_ Action class,
like so:
@ParentPackage(value="ApplicantTracking")
where "ApplicantTracking" is the name of my Struts package.
Thanks for the help,
Wes
-----Original Message-----
From: Gamble, Wesley (WG10) [mailto:WG10@tmw.com]
Sent: Tuesday, June 10, 2008 1:22 PM
To: Struts Users Mailing List; newton.dave@yahoo.com
Subject: Custom interceptor not firing
All,
I set up a custom interceptor, but it is not being invoked.
As far as I can tell from looking at _Struts 2 in Action_, I constructed
my class correctly. It is named "CompanyIdentificationInterceptor".
My struts.xml file now has this configuration in it to accommodate this
new interceptor:
<interceptors>
<interceptor name="companyInterceptor"
class="com.tmw.applicant.tracking.interceptors.CompanyIdentificationInte
rceptor" />
<interceptor-stack name="customStack">
<interceptor-ref name="companyInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="customStack" />
Have I missed something?
Thanks,
Wes
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Custom interceptor not firing
Posted by Michael Gagnon <mg...@genome.med.harvard.edu>.
You don't have any action mappings (that I see), so there's nothing for
these interceptors to apply to. Add the following to your web.xml:
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ActionContextCleanUp
</filter-class>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
And then add an action mapping to your struts xml, like:
<package name="ApplicantTracking" extends="tiles-default">
<interceptors>
<interceptor name="companyInterceptor"
class="com.tmw.applicant.tracking.interceptors.CompanyIdentificationInte
rceptor" />
<interceptor-stack name="customStack">
<interceptor-ref name="companyInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="customStack" />
<action name="Index" class="com.opensymphony.xwork2.ActionSupport">
<result name="success">/jsp/index.jsp</result>
</action>
</package>
Then when you go to http://(your-app-address)/ApplicantTracking/Index.action
You will see the interceptors apply
-----Original Message-----
From: Gamble, Wesley (WG10) [mailto:WG10@tmw.com]
Sent: Tuesday, June 10, 2008 3:03 PM
To: Struts Users Mailing List
Subject: RE: Custom interceptor not firing
I suspect that I don't have any interceptors firing at all. I can
change the value of "default-interceptor-ref" to "xxx" or anything and
nothing happens either on application startup or on action invocation.
Here is the entirety of my struts.xml file:
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.configuration.xml.reload" value="true" />
<constant name="struts.ui.theme" value="css_xhtml" />
<constant name="struts.custom.i18n.resources" value="global-messages"
/>
<constant name="struts.locale" value="en_US" />
<package name="ApplicantTracking" extends="tiles-default">
<interceptors>
<interceptor name="companyInterceptor"
class="com.tmw.applicant.tracking.interceptors.CompanyIdentificationInte
rceptor" />
<interceptor-stack name="customStack">
<interceptor-ref name="companyInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="customStack" />
</package>
</struts>
-----Original Message-----
From: Gamble, Wesley (WG10) [mailto:WG10@tmw.com]
Sent: Tuesday, June 10, 2008 1:22 PM
To: Struts Users Mailing List; newton.dave@yahoo.com
Subject: Custom interceptor not firing
My struts.xml file now has this configuration in it to accommodate this
new interceptor:
<interceptors>
<interceptor name="companyInterceptor"
class="com.tmw.applicant.tracking.interceptors.CompanyIdentificationInte
rceptor" />
<interceptor-stack name="customStack">
<interceptor-ref name="companyInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="customStack" />
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Custom interceptor not firing
Posted by "Gamble, Wesley (WG10)" <WG...@tmw.com>.
I suspect that I don't have any interceptors firing at all. I can
change the value of "default-interceptor-ref" to "xxx" or anything and
nothing happens either on application startup or on action invocation.
Here is the entirety of my struts.xml file:
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.configuration.xml.reload" value="true" />
<constant name="struts.ui.theme" value="css_xhtml" />
<constant name="struts.custom.i18n.resources" value="global-messages"
/>
<constant name="struts.locale" value="en_US" />
<package name="ApplicantTracking" extends="tiles-default">
<interceptors>
<interceptor name="companyInterceptor"
class="com.tmw.applicant.tracking.interceptors.CompanyIdentificationInte
rceptor" />
<interceptor-stack name="customStack">
<interceptor-ref name="companyInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="customStack" />
</package>
</struts>
-----Original Message-----
From: Gamble, Wesley (WG10) [mailto:WG10@tmw.com]
Sent: Tuesday, June 10, 2008 1:22 PM
To: Struts Users Mailing List; newton.dave@yahoo.com
Subject: Custom interceptor not firing
My struts.xml file now has this configuration in it to accommodate this
new interceptor:
<interceptors>
<interceptor name="companyInterceptor"
class="com.tmw.applicant.tracking.interceptors.CompanyIdentificationInte
rceptor" />
<interceptor-stack name="customStack">
<interceptor-ref name="companyInterceptor" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="customStack" />
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org