You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ken <ke...@aerose.com> on 2010/09/28 01:52:35 UTC

struts.xml parsing error, involving interceptor

This has been driving me nuts... 

The following works in my code (typed by hand not copied from source):
<struts>
    <!-- If I add the missing content (found below) HERE, then this does
NOT work -->
    <package namespace="/secure" name="secure" extends="struts-default">
        <result-types>
            <result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult"/>
        </result-types>
        <global-results>
            <result name="login" type="redirectAction">login</result>
        </global-results>
        <action name="test">
            <result name="success" type="tiles">/secure/welcome</result>
        </action>
    </package>
</struts>


*** This breaks the otherwise working struts.xml if inserted where the
commented line is above ***

<interceptors>
    <interceptor name="authenticationInterceptor"
            class="interceptors.Authentication"/>
    <interceptor-stack name="secureStack">
        <interceptor-ref name="authenticationInterceptor"/>
        <interceptor-ref name="defaultStack"/>
    </interceptor-stack>
</interceptors>
<default-interceptor-ref name="secureStack"/>

*** End content ***

Error states that there is a parsing error in the file included into
struts.xml... Need fresh eyes...

Oh at the top of each document for completeness:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC 
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

Thank you. 

Re: struts.xml parsing error, involving interceptor

Posted by Dave Newton <da...@gmail.com>.
Well, no, you need to follow the DTD.

Dave

On Mon, Sep 27, 2010 at 7:52 PM, Ken <ke...@aerose.com> wrote:

>
> This has been driving me nuts...
>
> The following works in my code (typed by hand not copied from source):
> <struts>
>    <!-- If I add the missing content (found below) HERE, then this does
> NOT work -->
>    <package namespace="/secure" name="secure" extends="struts-default">
>        <result-types>
>            <result-type name="tiles"
> class="org.apache.struts2.views.tiles.TilesResult"/>
>        </result-types>
>        <global-results>
>            <result name="login" type="redirectAction">login</result>
>        </global-results>
>        <action name="test">
>            <result name="success" type="tiles">/secure/welcome</result>
>        </action>
>    </package>
> </struts>
>
>
> *** This breaks the otherwise working struts.xml if inserted where the
> commented line is above ***
>
> <interceptors>
>    <interceptor name="authenticationInterceptor"
>            class="interceptors.Authentication"/>
>    <interceptor-stack name="secureStack">
>        <interceptor-ref name="authenticationInterceptor"/>
>        <interceptor-ref name="defaultStack"/>
>    </interceptor-stack>
> </interceptors>
> <default-interceptor-ref name="secureStack"/>
>
> *** End content ***
>
> Error states that there is a parsing error in the file included into
> struts.xml... Need fresh eyes...
>
> Oh at the top of each document for completeness:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>    "http://struts.apache.org/dtds/struts-2.0.dtd">
>
> Thank you.
>

Re: struts.xml parsing error, involving interceptor

Posted by Li Ying <li...@gmail.com>.
Hi Ken:

In the DTD file, it is defined:

<!ELEMENT package (result-types?, interceptors?, default-interceptor-ref?,
default-action-ref?, default-class-ref?, global-results?,
global-exception-mappings?, action*)>

That means, you should add the definition of interceptor
as children nodes of the [package] node.

Hope these helps.


2010/9/28 Ken <ke...@aerose.com>

>
> This has been driving me nuts...
>
> The following works in my code (typed by hand not copied from source):
> <struts>
>    <!-- If I add the missing content (found below) HERE, then this does
> NOT work -->
>    <package namespace="/secure" name="secure" extends="struts-default">
>        <result-types>
>            <result-type name="tiles"
> class="org.apache.struts2.views.tiles.TilesResult"/>
>        </result-types>
>        <global-results>
>            <result name="login" type="redirectAction">login</result>
>        </global-results>
>        <action name="test">
>            <result name="success" type="tiles">/secure/welcome</result>
>        </action>
>    </package>
> </struts>
>
>
> *** This breaks the otherwise working struts.xml if inserted where the
> commented line is above ***
>
> <interceptors>
>    <interceptor name="authenticationInterceptor"
>            class="interceptors.Authentication"/>
>    <interceptor-stack name="secureStack">
>        <interceptor-ref name="authenticationInterceptor"/>
>        <interceptor-ref name="defaultStack"/>
>    </interceptor-stack>
> </interceptors>
> <default-interceptor-ref name="secureStack"/>
>
> *** End content ***
>
> Error states that there is a parsing error in the file included into
> struts.xml... Need fresh eyes...
>
> Oh at the top of each document for completeness:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE struts PUBLIC
>    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>    "http://struts.apache.org/dtds/struts-2.0.dtd">
>
> Thank you.
>