You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dave Belfer-Shevett <db...@homeport.org> on 2008/07/16 05:53:12 UTC

'include' struts.xml stuff is broken?

This seems like it should work, but I'm getting all sorts of hassles, and 
the documentation page for this, naturally, provides no examples of what 
the include file should look like.

My struts.xml has...

<!DOCTYPE struts PUBLIC
     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
     "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
 	<include file="struts-editevent.xml">
 	<package name="CONGO" extends="struts-default">
 		<interceptors>
 		[blah blah blah]
 		</interceptors>
 	(more actions)
 	</package>
</struts>

The 'struts-editevent.xml' has:
 	<action name="coconut/viewEditEvent" method="load" 
class="com.stonekeep.congo.coconut.EditEvent">
 		<interceptor-ref name="mystack" />
 		<result 
name="success">/WEB-INF/jsp/coconut/EditEventForm.jsp</result>
 		<result name="login" 
type="redirect-action">coconut/showloginpage</result>
 	</action>

 	<action name="coconut/postEditEvent" method="update" 
class="com.stonekeep.congo.coconut.EditEvent">
 		<interceptor-ref name="mystack" />
 		<result 
name="success">/WEB-INF/jsp/coconut/Maintenance.jsp</result>
 		<result 
name="input">/WEB-INF/jsp/coconut/EditEventForm.jsp</result>
 		<result name="login" 
type="redirect-action">coconut/showloginpage</result>
 	</action>

A basic block of actions.

I'm getting XML validatoin errors up the wazoo because the 
struts-editevent.xml file isn't well-formed.  If I put it in <struts> 
blocks, I get "you're referencing interceptors that don't exist".

If I try and duplicate the entire package, interceptors, and DTD 
definition into the include file, I get package collisions.

My take is the <include> function does not work as described in the 
documentation.  It should be a linear include, and the resulting document 
is parsed by SAX, but that doesn't seem to be happening.

Can someone give me an example of an included XML file that actually 
works?

Here are links to what I'm seeing:
My main struts.xml: http://pastebin.stonekeep.com/4955

My struts-editevent.xml: http://pastebin.stonekeep.com/4956

What happens when I deploy:

http://pastebin.stonekeep.com/4957

Note that says "no grammar found".  Adding the DTD says "you need a 
package name in your struts block" - etc etc etc.  It never really 
resolves.

Can someone show me an <include> setup that actually works?

-- 
-------------------.--------.-------------------------------.
Dave Belfer-Shevett \ KB1FWR \ JID: dbs@jabber.stonekeep.com \
blog:planet-geek.com >--------'-----------------------------------.
dbs@homeport.org    /   Windows98 Err#021 - Error Parsing Error    \
-------------------<        List; Please Wait For Next Error        |
                     \______________________________________________/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: 'include' struts.xml stuff is broken?

Posted by Gabriel Belingueres <be...@gmail.com>.
In your struts-editevent.xml: http://pastebin.stonekeep.com/4956
<action> tags must be inside a <package>, and they are inside <struts>.

See the http://struts.apache.org/dtds/struts-2.0.dtd file

2008/7/16 Dave Belfer-Shevett <db...@homeport.org>:
> This seems like it should work, but I'm getting all sorts of hassles, and
> the documentation page for this, naturally, provides no examples of what the
> include file should look like.
>
> My struts.xml has...
>
> <!DOCTYPE struts PUBLIC
>    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>    "http://struts.apache.org/dtds/struts-2.0.dtd">
> <struts>
>        <include file="struts-editevent.xml">
>        <package name="CONGO" extends="struts-default">
>                <interceptors>
>                [blah blah blah]
>                </interceptors>
>        (more actions)
>        </package>
> </struts>
>
> The 'struts-editevent.xml' has:
>        <action name="coconut/viewEditEvent" method="load"
> class="com.stonekeep.congo.coconut.EditEvent">
>                <interceptor-ref name="mystack" />
>                <result
> name="success">/WEB-INF/jsp/coconut/EditEventForm.jsp</result>
>                <result name="login"
> type="redirect-action">coconut/showloginpage</result>
>        </action>
>
>        <action name="coconut/postEditEvent" method="update"
> class="com.stonekeep.congo.coconut.EditEvent">
>                <interceptor-ref name="mystack" />
>                <result
> name="success">/WEB-INF/jsp/coconut/Maintenance.jsp</result>
>                <result
> name="input">/WEB-INF/jsp/coconut/EditEventForm.jsp</result>
>                <result name="login"
> type="redirect-action">coconut/showloginpage</result>
>        </action>
>
> A basic block of actions.
>
> I'm getting XML validatoin errors up the wazoo because the
> struts-editevent.xml file isn't well-formed.  If I put it in <struts>
> blocks, I get "you're referencing interceptors that don't exist".
>
> If I try and duplicate the entire package, interceptors, and DTD definition
> into the include file, I get package collisions.
>
> My take is the <include> function does not work as described in the
> documentation.  It should be a linear include, and the resulting document is
> parsed by SAX, but that doesn't seem to be happening.
>
> Can someone give me an example of an included XML file that actually works?
>
> Here are links to what I'm seeing:
> My main struts.xml: http://pastebin.stonekeep.com/4955
>
> My struts-editevent.xml: http://pastebin.stonekeep.com/4956
>
> What happens when I deploy:
>
> http://pastebin.stonekeep.com/4957
>
> Note that says "no grammar found".  Adding the DTD says "you need a package
> name in your struts block" - etc etc etc.  It never really resolves.
>
> Can someone show me an <include> setup that actually works?
>
> --
> -------------------.--------.-------------------------------.
> Dave Belfer-Shevett \ KB1FWR \ JID: dbs@jabber.stonekeep.com \
> blog:planet-geek.com >--------'-----------------------------------.
> dbs@homeport.org    /   Windows98 Err#021 - Error Parsing Error    \
> -------------------<        List; Please Wait For Next Error        |
>                    \______________________________________________/
>
> ---------------------------------------------------------------------
> 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: 'include' struts.xml stuff is broken?

Posted by Wes Wannemacher <we...@wantii.com>.
When you use an include, the entire included document is parsed and
added to the configuration. This means that the included document must
work as if it were a stand-alone configuration file. You'll have to not
only create well-formed struts xml files, but package configuration as
well. If you're going to reuse interceptors, etc., then you'll need to
pull them in with "extends".

-Wes

On Tue, 2008-07-15 at 23:53 -0400, Dave Belfer-Shevett wrote:
> This seems like it should work, but I'm getting all sorts of hassles, and 
> the documentation page for this, naturally, provides no examples of what 
> the include file should look like.
> 
> My struts.xml has...
> 
> <!DOCTYPE struts PUBLIC
>      "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>      "http://struts.apache.org/dtds/struts-2.0.dtd">
> <struts>
>  	<include file="struts-editevent.xml">
>  	<package name="CONGO" extends="struts-default">
>  		<interceptors>
>  		[blah blah blah]
>  		</interceptors>
>  	(more actions)
>  	</package>
> </struts>
> 
> The 'struts-editevent.xml' has:
>  	<action name="coconut/viewEditEvent" method="load" 
> class="com.stonekeep.congo.coconut.EditEvent">
>  		<interceptor-ref name="mystack" />
>  		<result 
> name="success">/WEB-INF/jsp/coconut/EditEventForm.jsp</result>
>  		<result name="login" 
> type="redirect-action">coconut/showloginpage</result>
>  	</action>
> 
>  	<action name="coconut/postEditEvent" method="update" 
> class="com.stonekeep.congo.coconut.EditEvent">
>  		<interceptor-ref name="mystack" />
>  		<result 
> name="success">/WEB-INF/jsp/coconut/Maintenance.jsp</result>
>  		<result 
> name="input">/WEB-INF/jsp/coconut/EditEventForm.jsp</result>
>  		<result name="login" 
> type="redirect-action">coconut/showloginpage</result>
>  	</action>
> 
> A basic block of actions.
> 
> I'm getting XML validatoin errors up the wazoo because the 
> struts-editevent.xml file isn't well-formed.  If I put it in <struts> 
> blocks, I get "you're referencing interceptors that don't exist".
> 
> If I try and duplicate the entire package, interceptors, and DTD 
> definition into the include file, I get package collisions.
> 
> My take is the <include> function does not work as described in the 
> documentation.  It should be a linear include, and the resulting document 
> is parsed by SAX, but that doesn't seem to be happening.
> 
> Can someone give me an example of an included XML file that actually 
> works?
> 
> Here are links to what I'm seeing:
> My main struts.xml: http://pastebin.stonekeep.com/4955
> 
> My struts-editevent.xml: http://pastebin.stonekeep.com/4956
> 
> What happens when I deploy:
> 
> http://pastebin.stonekeep.com/4957
> 
> Note that says "no grammar found".  Adding the DTD says "you need a 
> package name in your struts block" - etc etc etc.  It never really 
> resolves.
> 
> Can someone show me an <include> setup that actually works?
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: 'include' struts.xml stuff is broken?

Posted by Dave Newton <ne...@yahoo.com>.
--- On Wed, 7/16/08, Dave Belfer-Shevett <db...@homeport.org> wrote:
> And was completely unmentioned in the document I was looking at:

Sorry we didn't put it where you looked. In general I usually recommend looking at core documentation in addition to FAQs, it provides context for the more free-form, supplementary nature of FAQs.

I've changed the FAQ entry [1] to point to the core documentation. (Note that changes are not immediately visible.)

> That FAQ should have had a link along the lines of
> "Full documentation for include is [here...].

Feel free to file a CLA and contribute to the documentation or file JIRA issues against existing documentation; input and contributions are helpful and appreciated (even more so without sniping and implied obligation :)

> What neither document mentions is how to configure both the
> top level struts.xml and the secondary files to avoid duplicating
> entire interceptor stacks using packages.

You lost me there; once an element (interceptor, stack, whatever) is defined it's available to subsequent elements. The <package...> documentation [2] describes the use of the "extends" attribute and states:

"The extends attribute is optional and allows one package to inherit the configuration of one or more previous packages - including all interceptor, interceptor-stack, and action configurations."

Dave

[1] Breaking up config files FAQ entry:
http://struts.apache.org/2.x/docs/can-we-break-up-a-large-strutsxml-file-into-smaller-pieces.html

[2] <package...> documentation:
http://struts.apache.org/2.x/docs/package-configuration.html


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: 'include' struts.xml stuff is broken?

Posted by Dave Belfer-Shevett <db...@homeport.org>.
On Wed, 16 Jul 2008, Dave Newton wrote:
> --- On Tue, 7/15/08, Dave Belfer-Shevett <db...@homeport.org> wrote:
>> [...] the documentation page for this, naturally, provides
>> no examples of what the include file should look like.
>
> "Naturally?"
>
> Sniping aside: the "include" documentation [1] states the following:
>
> "Each included file must be in the same format as struts.xml, including the DOCTYPE. The include files can be placed anywhere on the classpath and should be referred to by that path by the "file" attribute."
>
> To me that implies a well-formed, complete S2 config file.

And was completely unmentioned in the document I was looking at:
http://struts.apache.org/2.x/docs/can-we-break-up-a-large-strutsxml-file-into-smaller-pieces.html

That FAQ should have had a link along the lines of "Full documentation for 
include is [here...].

What neither document mentions is how to configure both the top level 
struts.xml and the secondary files to avoid duplicating entire interceptor 
stacks using packages.  1-2 lines referring to other bits of information 
would have been enormously helpful.

I did finally get it working, using an <include> in struts.xml, and in the 
included struts.xml, added dtd, a new package definition, and an 
'extends=' reference to the parent package.


-- 
-------------------.--------.-------------------------------.
Dave Belfer-Shevett \ KB1FWR \ JID: dbs@jabber.stonekeep.com \
blog:planet-geek.com >--------'-----------------------------------.
dbs@homeport.org    /   Windows98 Err#021 - Error Parsing Error    \
-------------------<        List; Please Wait For Next Error        |
                     \______________________________________________/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: 'include' struts.xml stuff is broken?

Posted by Dave Newton <ne...@yahoo.com>.
In addition to the other replies, I'll add my own.

--- On Tue, 7/15/08, Dave Belfer-Shevett <db...@homeport.org> wrote:
> [...] the documentation page for this, naturally, provides 
> no examples of what the include file should look like.

"Naturally?"

Sniping aside: the "include" documentation [1] states the following:

"Each included file must be in the same format as struts.xml, including the DOCTYPE. The include files can be placed anywhere on the classpath and should be referred to by that path by the "file" attribute."

To me that implies a well-formed, complete S2 config file.

> It should be a linear include, and the resulting document 
> is parsed by SAX, but that doesn't seem to be happening.

I don't know if "should" is an appropriate word here. It may not meet your expectations, but it works as described, and in some ways is better than a linear include.

Dave

[1] "include" documentation:
http://struts.apache.org/2.x/docs/include-configuration.html



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org