You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by RogerV <ro...@googlemail.com> on 2009/09/11 08:22:10 UTC

Global Exceptions with Convention Plugin

Hi

My project is using Struts 2.1.6 based on blank.war with the convention
plugin enabled. I'm having a problem getting global exception catching to
work - I'm still getting the stack trace displayed in the browser. Do I need
to add anything that would not be available "out of the box" having started
with importing blank.war into my ide. I've attached my struts.xml below.

Regards

<?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">

<struts>

    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="true" />

        <package name="default" namespace="/" extends="struts-default">
        
        <default-action-ref name="index" />
        
        <global-exception-mappings>
           <exception-mapping
exception="javax.persistence.OptimisticLockException" result="input"/>
                      <exception-mapping
exception="org.eclipse.persistemce.exceptions.OptimisticLockException"
result="input"/>
        </global-exception-mappings> 
        
        
        
        
        
        <action name="index">
            <result type="redirectAction">
                menu
            </result>
        </action>
    </package>

    <!-- Add packages here -->

</struts> 
-- 
View this message in context: http://www.nabble.com/Global-Exceptions-with-Convention-Plugin-tp25395678p25395678.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Global Exceptions with Convention Plugin

Posted by Paweł Wielgus <po...@gmail.com>.
Hi again,
yes i do define struts.convention.default.parent.package=default
but in order to have all action mapping created by convention added
parent package "default"
so that i can use this in my security interceptor.

Who knows, maybe it's corelated, i don't know.

But what i know for sure is
double check your configuration with config browser plugin.
http://poulwiel.blogspot.com/2009/09/config-browser-plugin-in-struts2.html

Best greetings,
Paweł Wielgus.



2009/9/17 RogerV <ro...@googlemail.com>:
>
>
>
> Paweł Wielgus wrote:
>>
>> Hi Roger,
>> i'm using convention in all my actual projects,
>> i also use global result with no problems like this:
>>       <global-results>
>>               <result name="login-input">/WEB-INF/pages/login-input.jsp</result>
>>       </global-results>
>>
>> Best greetings,
>> Paweł Wielgus.
>>
>
> Hi Pawel
>
> Do you define <constant name="struts.convention.default.parent.package"
> value="xxxxx"/> to make this work? I've added a "button" to all my jsp pages
> to allow my users to go back to the main menu page. The button calls a
> method menu() which is defined in a baseAction which all my actions extend.
> I know that the menu() method is being called successfully, but Struts
> remains at the jsp page where I hit the button.
>
> Regards
> Roger
>
> --
> View this message in context: http://www.nabble.com/Global-Exceptions-with-Convention-Plugin-tp25395678p25490230.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: Global Exceptions with Convention Plugin

Posted by RogerV <ro...@googlemail.com>.


Paweł Wielgus wrote:
> 
> Hi Roger,
> i'm using convention in all my actual projects,
> i also use global result with no problems like this:
> 	<global-results>
> 		<result name="login-input">/WEB-INF/pages/login-input.jsp</result>
> 	</global-results>
> 
> Best greetings,
> Paweł Wielgus.
> 

Hi Pawel

Do you define <constant name="struts.convention.default.parent.package"
value="xxxxx"/> to make this work? I've added a "button" to all my jsp pages
to allow my users to go back to the main menu page. The button calls a
method menu() which is defined in a baseAction which all my actions extend.
I know that the menu() method is being called successfully, but Struts
remains at the jsp page where I hit the button.

Regards
Roger

-- 
View this message in context: http://www.nabble.com/Global-Exceptions-with-Convention-Plugin-tp25395678p25490230.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Global Exceptions with Convention Plugin

Posted by Paweł Wielgus <po...@gmail.com>.
Hi Roger,
i'm using convention in all my actual projects,
i also use global result with no problems like this:
	<global-results>
		<result name="login-input">/WEB-INF/pages/login-input.jsp</result>
	</global-results>

Best greetings,
Paweł Wielgus.



2009/9/17 RogerV <ro...@googlemail.com>:
>
>
>
> Wes Wannemacher wrote:
>>
>> The conventions plugin has a variable (constant) that you have to set
>> so that your conventions actions extend a package other than
>> conventions-default... It is toward the bottom of the page of the
>> conventions plugin docs.
>>
>
> I've now amended my struts.xml (below) but the global exception mapping
> still doesn't work (stack trace in the browser) and the global result
> doesn't work either (leaves me on the same page) - so I'd be grateful for
> suggestions.
>
> As an aside, how widely are people using the convention-plugin? While
> googling when things go wrong, other than the convention-plugin doc, there
> seems to be very little about. Even the convention-plugin doc doesn't
> actually specify why I would want to change the package extension. Would I
> be better off forgetting the convention plugin and go back to the tried and
> tested xml configuration?
>
> Regards
>
> <struts>
>
>    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
>    <constant name="struts.devMode" value="true" />
>    <constant name="struts.convention.default.parent.package"
> value="default"/>
>
>        <package name="default" namespace="/" extends="struts-default">
>
>        <default-action-ref name="index" />
>
>        <global-results>
>        <result name="menu" type="redirectAction">menu</result>
>        </global-results>
>
>
>        <global-exception-mappings>
>           <exception-mapping
> exception="javax.persistence.OptimisticLockException" result="input"/>
>                      <exception-mapping
> exception="org.eclipse.persistemce.exceptions.OptimisticLockException"
> result="input"/>
>        </global-exception-mappings>
>
>
>
>
>
>        <action name="index">
>            <result type="redirectAction">
>                menu
>            </result>
>        </action>
>    </package>
>
>    <!-- Add packages here -->
>
> </struts>
>
> --
> View this message in context: http://www.nabble.com/Global-Exceptions-with-Convention-Plugin-tp25395678p25489004.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: Global Exceptions with Convention Plugin

Posted by RogerV <ro...@googlemail.com>.


Wes Wannemacher wrote:
> 
> The conventions plugin has a variable (constant) that you have to set
> so that your conventions actions extend a package other than
> conventions-default... It is toward the bottom of the page of the
> conventions plugin docs.
> 

I've now amended my struts.xml (below) but the global exception mapping
still doesn't work (stack trace in the browser) and the global result
doesn't work either (leaves me on the same page) - so I'd be grateful for
suggestions.

As an aside, how widely are people using the convention-plugin? While
googling when things go wrong, other than the convention-plugin doc, there
seems to be very little about. Even the convention-plugin doc doesn't
actually specify why I would want to change the package extension. Would I
be better off forgetting the convention plugin and go back to the tried and
tested xml configuration?

Regards

<struts>

    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="true" />
    <constant name="struts.convention.default.parent.package"
value="default"/> 

        <package name="default" namespace="/" extends="struts-default">
        
        <default-action-ref name="index" />
        
        <global-results>
        <result name="menu" type="redirectAction">menu</result>
        </global-results>
        
        
        <global-exception-mappings>
           <exception-mapping
exception="javax.persistence.OptimisticLockException" result="input"/>
                      <exception-mapping
exception="org.eclipse.persistemce.exceptions.OptimisticLockException"
result="input"/>
        </global-exception-mappings> 
        
        
        
        
        
        <action name="index">
            <result type="redirectAction">
                menu
            </result>
        </action>
    </package>

    <!-- Add packages here -->

</struts>  

-- 
View this message in context: http://www.nabble.com/Global-Exceptions-with-Convention-Plugin-tp25395678p25489004.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Global Exceptions with Convention Plugin

Posted by Wes Wannemacher <we...@wantii.com>.
The conventions plugin has a variable (constant) that you have to set
so that your conventions actions extend a package other than
conventions-default... It is toward the bottom of the page of the
conventions plugin docs.

-Wes

On Fri, Sep 11, 2009 at 2:22 AM, RogerV <ro...@googlemail.com> wrote:
>
> Hi
>
> My project is using Struts 2.1.6 based on blank.war with the convention
> plugin enabled. I'm having a problem getting global exception catching to
> work - I'm still getting the stack trace displayed in the browser. Do I need
> to add anything that would not be available "out of the box" having started
> with importing blank.war into my ide. I've attached my struts.xml below.
>
> Regards
>
> <?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">
>
> <struts>
>
>    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
>    <constant name="struts.devMode" value="true" />
>
>        <package name="default" namespace="/" extends="struts-default">
>
>        <default-action-ref name="index" />
>
>        <global-exception-mappings>
>           <exception-mapping
> exception="javax.persistence.OptimisticLockException" result="input"/>
>                      <exception-mapping
> exception="org.eclipse.persistemce.exceptions.OptimisticLockException"
> result="input"/>
>        </global-exception-mappings>
>
>
>
>
>
>        <action name="index">
>            <result type="redirectAction">
>                menu
>            </result>
>        </action>
>    </package>
>
>    <!-- Add packages here -->
>
> </struts>
> --
> View this message in context: http://www.nabble.com/Global-Exceptions-with-Convention-Plugin-tp25395678p25395678.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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