struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steven Yang <kenshin...@gmail.com>
Subject interceptor init twice
Date Wed, 24 Apr 2013 11:52:09 GMT
I was using 2.1.8 and recently upgraded to 2.3.14.
And I realized that my interceptor got initialized twice and it didnt
happen before.

This happens when I declare a default package in struts.xml and include
other xml which have packages that extends my default package. But the
thing is no matter how many more xml I include the interceptor will only be
initialize one extra time.

the following is my sample struts.xml

 <package name="default" namespace="/" extends="struts-default">

<interceptors>
<interceptor name="baseGeneral" class="GeneralInterceptor"></interceptor>
<interceptor-stack name="biStack">
<interceptor-ref name="baseGeneral"/>
</interceptor-stack>
</interceptors>
        <default-action-ref name="index" />

        <global-results>
            <result name="error">/error.jsp</result>
        </global-results>

        <global-exception-mappings>
            <exception-mapping exception="java.lang.Exception"
result="error"/>
        </global-exception-mappings>

        <action name="index">
            <result type="redirectAction">
                <param name="actionName">HelloWorld</param>
                <param name="namespace">/example</param>
            </result>
        </action>
    </package>

    <include file="example.xml"/>

my example.xml

  <package name="example" namespace="/example" extends="default">

        <action name="HelloWorld" class="example.HelloWorld">
            <result>/example/HelloWorld.jsp</result>
        </action>
</package>

I traced the log and see the that my default package is been initialized
twice and it seems that struts knows about it but it still called init() on
my interceptor.
partial log:

2013-04-24 11:57:58,504 DEBUG
com.opensymphony.xwork2.util.logging.slf4j.Slf4jLogger
(Slf4jLogger.java:69) - Using default implementation of FileManager
provided under name [system]: DefaultFileManager
2013-04-24 11:57:58,505 DEBUG
com.opensymphony.xwork2.util.logging.slf4j.Slf4jLogger
(Slf4jLogger.java:69) - Loaded [BUILDER] {PackageConfig Name:default
namespace:/ parents:[{PackageConfig Name:struts-default namespace:
parents:[]}]}
GeneralInterceptor.init()
2013-04-24 11:57:58,509 DEBUG
com.opensymphony.xwork2.util.logging.slf4j.Slf4jLogger
(Slf4jLogger.java:69) - Loaded //index in 'default' package:{ActionConfig
index () - action -
file:/D:/workspace_tsb/struts2-blank/build/classes/struts.xml:30:30}
2013-04-24 11:57:58,510 DEBUG
com.opensymphony.xwork2.util.logging.slf4j.Slf4jLogger
(Slf4jLogger.java:69) - Loaded [BUILDER] {PackageConfig Name:example
namespace:/example parents:[{PackageConfig Name:default namespace:/
parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}]}
2013-04-24 11:57:58,513 DEBUG
com.opensymphony.xwork2.util.logging.slf4j.Slf4jLogger
(Slf4jLogger.java:69) - Loaded /example/HelloWorld in 'example'
package:{ActionConfig HelloWorld (example.HelloWorld) - action -
file:/D:/workspace_tsb/struts2-blank/build/classes/example.xml:10:62}
2013-04-24 11:57:58,514 DEBUG
com.opensymphony.xwork2.util.logging.slf4j.Slf4jLogger
(Slf4jLogger.java:69) - Loaded /example/Login_* in 'example'
package:{ActionConfig Login_* (example.Login.{1}()) - action -
file:/D:/workspace_tsb/struts2-blank/build/classes/example.xml:14:67}
2013-04-24 11:57:58,514 DEBUG
com.opensymphony.xwork2.util.logging.slf4j.Slf4jLogger
(Slf4jLogger.java:69) - Loaded /example/* in 'example'
package:{ActionConfig * (example.ExampleSupport) - action -
file:/D:/workspace_tsb/struts2-blank/build/classes/example.xml:19:57}
2013-04-24 11:57:58,515 DEBUG
com.opensymphony.xwork2.util.logging.slf4j.Slf4jLogger
(Slf4jLogger.java:69) - Loaded [BUILDER] {PackageConfig Name:default
namespace:/ parents:[{PackageConfig Name:struts-default namespace:
parents:[]}]}
GeneralInterceptor.init()
2013-04-24 11:57:58,516 DEBUG
com.opensymphony.xwork2.util.logging.slf4j.Slf4jLogger
(Slf4jLogger.java:69) - Loaded //index in 'default' package:{ActionConfig
index () - action -
file:/D:/workspace_tsb/struts2-blank/build/classes/struts.xml:30:30}
2013-04-24 11:57:58,516 DEBUG
com.opensymphony.xwork2.util.logging.slf4j.Slf4jLogger
(Slf4jLogger.java:69) - The package name 'default' is already been loaded
by the same location and could be removed: package -
file:/D:/workspace_tsb/struts2-blank/build/classes/struts.xml:11:68


as you can see struts knows that "default" has been loaded before however
my interceptor still prints out init message.

If I remove the include or move the "default" package declaration out to
another file and use include to include it in struts.xml the problem goes
away.

Is this behavior correct? or I am using something in the wrong way?

Thanks

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message