You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Lukasz Lichota <lu...@ocado.com> on 2013/11/26 13:44:35 UTC

Sending email on uncought exception problems

hello,

I'd like to run some java code on any uncought exception but so far I
cannot find a solution.
Under this link I found the exactly same question but I do not know how to
apply solution.
http://markmail.org/search/?q=global+exception+redirect+list%3Aorg.apache.struts.users%2F#query:global%20exception%20redirect%20list%3Aorg.apache.struts.users%2F+page:1+mid:wmzqlmfqpzd57dhg+state:results

Namely if I have
<s:if test="notifyAdmin(exception)"></s:if>
then in which class this method should be? Error.jsp is not associated with
any action. The author says he has this method in any Action class but for
me it doesn't work (how could it work anyway? how error.jsp know about any
Action class?

I tried also s:action element like that:
<s:action name="default-error!notifyAdmin" executeResult="false">
<s:param>%{exception}</s:param>
</s:action>
 and having java class with method like that:
@Action("default-error")
public boolean notifyAdmin(Exception exception)

but it fails with no error message so I even do not know what is happening
(by failing I mean nothing is invoked when rendering the error page)

I also found this
http://www.mkyong.com/struts/struts-global-custom-exception-example/ but it
looks like exception handler was removed in struts 2.0

Can you offer any hint?

Thanks
Lukasz

-- 
Notice:  This email is confidential and may contain copyright material of 
Ocado Limited (the "Company"). Opinions and views expressed in this message 
may not necessarily reflect the opinions and views of the Company.

If you are not the intended recipient, please notify us immediately and 
delete all copies of this message. Please note that it is your 
responsibility to scan this message for viruses.

Company reg. no. 3875000.

Ocado Limited
Titan Court
3 Bishops Square
Hatfield Business Park
Hatfield
Herts
AL10 9NE

Re: Sending email on uncought exception problems

Posted by Miguel Almeida <mi...@almeida.at>.
The first thought I had was also that this might be better suited on an
interceptor. You'll also have more control over the desired behaviour
since interceptors are more easily testable than JSPs.

Miguel
On Tue, 2013-11-26 at 09:43 -0500, Dave Newton wrote:

> Why not use an interceptor?
> 
> Dave
> 
> 
> 
> On Tue, Nov 26, 2013 at 7:44 AM, Lukasz Lichota <lu...@ocado.com>wrote:
> 
> > hello,
> >
> > I'd like to run some java code on any uncought exception but so far I
> > cannot find a solution.
> > Under this link I found the exactly same question but I do not know how to
> > apply solution.
> >
> > http://markmail.org/search/?q=global+exception+redirect+list%3Aorg.apache.struts.users%2F#query:global%20exception%20redirect%20list%3Aorg.apache.struts.users%2F+page:1+mid:wmzqlmfqpzd57dhg+state:results
> >
> > Namely if I have
> > <s:if test="notifyAdmin(exception)"></s:if>
> > then in which class this method should be? Error.jsp is not associated with
> > any action. The author says he has this method in any Action class but for
> > me it doesn't work (how could it work anyway? how error.jsp know about any
> > Action class?
> >
> > I tried also s:action element like that:
> > <s:action name="default-error!notifyAdmin" executeResult="false">
> > <s:param>%{exception}</s:param>
> > </s:action>
> >  and having java class with method like that:
> > @Action("default-error")
> > public boolean notifyAdmin(Exception exception)
> >
> > but it fails with no error message so I even do not know what is happening
> > (by failing I mean nothing is invoked when rendering the error page)
> >
> > I also found this
> > http://www.mkyong.com/struts/struts-global-custom-exception-example/ but
> > it
> > looks like exception handler was removed in struts 2.0
> >
> > Can you offer any hint?
> >
> > Thanks
> > Lukasz
> >
> > --
> > Notice:  This email is confidential and may contain copyright material of
> > Ocado Limited (the "Company"). Opinions and views expressed in this message
> > may not necessarily reflect the opinions and views of the Company.
> >
> > If you are not the intended recipient, please notify us immediately and
> > delete all copies of this message. Please note that it is your
> > responsibility to scan this message for viruses.
> >
> > Company reg. no. 3875000.
> >
> > Ocado Limited
> > Titan Court
> > 3 Bishops Square
> > Hatfield Business Park
> > Hatfield
> > Herts
> > AL10 9NE
> >
> 
> 
> 



Re: Sending email on uncought exception problems

Posted by Dave Newton <da...@gmail.com>.
Why not use an interceptor?

Dave



On Tue, Nov 26, 2013 at 7:44 AM, Lukasz Lichota <lu...@ocado.com>wrote:

> hello,
>
> I'd like to run some java code on any uncought exception but so far I
> cannot find a solution.
> Under this link I found the exactly same question but I do not know how to
> apply solution.
>
> http://markmail.org/search/?q=global+exception+redirect+list%3Aorg.apache.struts.users%2F#query:global%20exception%20redirect%20list%3Aorg.apache.struts.users%2F+page:1+mid:wmzqlmfqpzd57dhg+state:results
>
> Namely if I have
> <s:if test="notifyAdmin(exception)"></s:if>
> then in which class this method should be? Error.jsp is not associated with
> any action. The author says he has this method in any Action class but for
> me it doesn't work (how could it work anyway? how error.jsp know about any
> Action class?
>
> I tried also s:action element like that:
> <s:action name="default-error!notifyAdmin" executeResult="false">
> <s:param>%{exception}</s:param>
> </s:action>
>  and having java class with method like that:
> @Action("default-error")
> public boolean notifyAdmin(Exception exception)
>
> but it fails with no error message so I even do not know what is happening
> (by failing I mean nothing is invoked when rendering the error page)
>
> I also found this
> http://www.mkyong.com/struts/struts-global-custom-exception-example/ but
> it
> looks like exception handler was removed in struts 2.0
>
> Can you offer any hint?
>
> Thanks
> Lukasz
>
> --
> Notice:  This email is confidential and may contain copyright material of
> Ocado Limited (the "Company"). Opinions and views expressed in this message
> may not necessarily reflect the opinions and views of the Company.
>
> If you are not the intended recipient, please notify us immediately and
> delete all copies of this message. Please note that it is your
> responsibility to scan this message for viruses.
>
> Company reg. no. 3875000.
>
> Ocado Limited
> Titan Court
> 3 Bishops Square
> Hatfield Business Park
> Hatfield
> Herts
> AL10 9NE
>



-- 
e: davelnewton@gmail.com
m: 908-380-8699
s: davelnewton_skype
t: @dave_newton <https://twitter.com/dave_newton>
b: Bucky Bits <http://buckybits.blogspot.com/>
g: davelnewton <https://github.com/davelnewton>
so: Dave Newton <http://stackoverflow.com/users/438992/dave-newton>

Re: Sending email on uncought exception problems

Posted by Lukasz Lenart <lu...@apache.org>.
2013/11/26 Lukasz Lichota <lu...@ocado.com>:
> I tried it but it did not work (unless I did something wrong). If any
> action is on ValueStack, why should I add it to base class and not to any
> random action I pick up?

ValueStack is per created per request, so you don't know which action
exactly it will be.


Regards
-- 
Łukasz
+ 48 606 323 122 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: Sending email on uncought exception problems

Posted by Lukasz Lichota <lu...@ocado.com>.
On 26 November 2013 15:29, Lukasz Lenart <lu...@apache.org> wrote:

>
> Any action is always available on ValueStack, so you must add
> notifyAdmin(exception) to the base action class.
>
>
I tried it but it did not work (unless I did something wrong). If any
action is on ValueStack, why should I add it to base class and not to any
random action I pick up?

Thanks
Lukasz

-- 
Notice:  This email is confidential and may contain copyright material of 
Ocado Limited (the "Company"). Opinions and views expressed in this message 
may not necessarily reflect the opinions and views of the Company.

If you are not the intended recipient, please notify us immediately and 
delete all copies of this message. Please note that it is your 
responsibility to scan this message for viruses.

Company reg. no. 3875000.

Ocado Limited
Titan Court
3 Bishops Square
Hatfield Business Park
Hatfield
Herts
AL10 9NE

Re: Sending email on uncought exception problems

Posted by Lukasz Lenart <lu...@apache.org>.
2013/11/26 Lukasz Lichota <lu...@ocado.com>:
> hello,
>
> I'd like to run some java code on any uncought exception but so far I
> cannot find a solution.
> Under this link I found the exactly same question but I do not know how to
> apply solution.
> http://markmail.org/search/?q=global+exception+redirect+list%3Aorg.apache.struts.users%2F#query:global%20exception%20redirect%20list%3Aorg.apache.struts.users%2F+page:1+mid:wmzqlmfqpzd57dhg+state:results
>
> Namely if I have
> <s:if test="notifyAdmin(exception)"></s:if>
> then in which class this method should be? Error.jsp is not associated with
> any action. The author says he has this method in any Action class but for
> me it doesn't work (how could it work anyway? how error.jsp know about any
> Action class?
>
> I tried also s:action element like that:
> <s:action name="default-error!notifyAdmin" executeResult="false">
> <s:param>%{exception}</s:param>
> </s:action>
>  and having java class with method like that:
> @Action("default-error")
> public boolean notifyAdmin(Exception exception)
>
> but it fails with no error message so I even do not know what is happening
> (by failing I mean nothing is invoked when rendering the error page)
>
> I also found this
> http://www.mkyong.com/struts/struts-global-custom-exception-example/ but it
> looks like exception handler was removed in struts 2.0
>
> Can you offer any hint?

Any action is always available on ValueStack, so you must add
notifyAdmin(exception) to the base action class.


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

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