You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Adrian CHIA <ad...@dbs.com> on 2016/07/26 08:14:12 UTC

Exception Mapping Annotation seems not inhierted

Hi

It seems that the struts 2.3.4.1 Exception Mapping annotation cannot be inherited by the sub-classes. I attempted to put the annotation in the base class but the child class is unable to inherit the exception mapping. However results view can be inherited. Please advise ?

With regards
Adrian Chia

CONFIDENTIAL NOTE:
The information contained in this email is intended only for the use of the individual or entity named above and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete the mail. Thank you.

RE: Exception Mapping Annotation seems not inhierted

Posted by Adrian CHIA <ad...@dbs.com>.
Hi Łukasz



Sorry I meant to say that result mappings defined in the base class are being "inherited"  in the child class. I believe the framework actually will look for the result in the parent class if it cannot be found in itself. Anyway I updated the ExceptionMapping annotation with @Inherited so that my actions which extends this base class will inherit the exception handling.



Alternatively, I tried defining the global exceptions handling in the struts xml however it seems I cannot get it working together with annotation configurations. Information as listed below.



I defined this in the struts.xml



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

<global-results>

    <result name="exception">/ error/error.jsp</result>

    <result name="runtime_exception"> /error/error.jsp</result>

    <result name="error"> error/error.jsp</result>

</global-results>

<global-exception-mappings>

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

    <exception-mapping exception="java.lang.Error" result="error"></exception-mapping>

    <exception-mapping exception="java.lang.RuntimeException" result="runtime_exception"></exception-mapping>

</global-exception-mappings>

</package>



Then I have this in the package-info



@ParentPackage(value="struts-default")

@Namespace("/dbsweb-forms/personal-loan")



package com.dbs.ploan.action;

import org.apache.struts2.convention.annotation.Namespace;

import org.apache.struts2.convention.annotation.ParentPackage;



In the Configuration Browser Plugin



The global exceptions mapping and result mapping are not listed here and when I hit the action throwing the exception I did not get to see the error page.

[cid:image001.png@01D1E81C.DD63F960]



With regards

Adrian Chia



-----Original Message-----
From: Lukasz Lenart [mailto:lukaszlenart@apache.org]
Sent: Wednesday, July 27, 2016 2:52 PM
To: Struts Developers List
Subject: Re: Exception Mapping Annotation seems not inhierted



2016-07-26 10:14 GMT+02:00 Adrian CHIA <ad...@dbs.com>>:

> Hi

>

> It seems that the struts 2.3.4.1 Exception Mapping annotation cannot be inherited by the sub-classes. I attempted to put the annotation in the base class but the child class is unable to inherit the exception mapping. However results view can be inherited. Please advise ?



As far I see, it works that way from the very beginning. You can always define global-exception-mappings in struts.xml. Also what do you mean by that the "results view can be inherited" ?

@Results/@Result are defined without "@Inherited" meta-annotation so they work the same, they aren't inherited by child classes.





Regards

--

Łukasz

+ 48 606 323 122 http://www.lenart.org.pl/



---------------------------------------------------------------------

To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org<ma...@struts.apache.org>

For additional commands, e-mail: dev-help@struts.apache.org<ma...@struts.apache.org>



CONFIDENTIAL NOTE:
The information contained in this email is intended only for the use of the individual or entity named above and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete the mail. Thank you.

RE: Exception Mapping Annotation seems not inhierted

Posted by Adrian CHIA <ad...@dbs.com>.
Hi Lukaz

You can ignore my email, as I realized that the package-info is not updated to refer to the package defined in the xml.

With regards
Adrian Chia
Mobile: +65 93650999

From: Adrian CHIA
Sent: Wednesday, July 27, 2016 3:38 PM
To: Struts Developers List
Subject: RE: Exception Mapping Annotation seems not inhierted


Hi Łukasz



Sorry I meant to say that result mappings defined in the base class are being "inherited"  in the child class. I believe the framework actually will look for the result in the parent class if it cannot be found in itself. Anyway I updated the ExceptionMapping annotation with @Inherited so that my actions which extends this base class will inherit the exception handling.



Alternatively, I tried defining the global exceptions handling in the struts xml however it seems I cannot get it working together with annotation configurations. Information as listed below.



I defined this in the struts.xml



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

<global-results>

    <result name="exception">/ error/error.jsp</result>

    <result name="runtime_exception"> /error/error.jsp</result>

    <result name="error"> error/error.jsp</result>

</global-results>



<global-exception-mappings>

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

    <exception-mapping exception="java.lang.Error" result="error"></exception-mapping>

    <exception-mapping exception="java.lang.RuntimeException" result="runtime_exception"></exception-mapping>

</global-exception-mappings>

</package>



Then I have this in the package-info



@ParentPackage(value="struts-default")

@Namespace("/dbsweb-forms/personal-loan")



package com.dbs.ploan.action;

import org.apache.struts2.convention.annotation.Namespace;

import org.apache.struts2.convention.annotation.ParentPackage;



In the Configuration Browser Plugin



The global exceptions mapping and result mapping are not listed here and when I hit the action throwing the exception I did not get to see the error page.

[cid:image001.png@01D1E81F.008AC660]



With regards

Adrian Chia



-----Original Message-----
From: Lukasz Lenart [mailto:lukaszlenart@apache.org]
Sent: Wednesday, July 27, 2016 2:52 PM
To: Struts Developers List
Subject: Re: Exception Mapping Annotation seems not inhierted



2016-07-26 10:14 GMT+02:00 Adrian CHIA <ad...@dbs.com>>:

> Hi

>

> It seems that the struts 2.3.4.1 Exception Mapping annotation cannot be inherited by the sub-classes. I attempted to put the annotation in the base class but the child class is unable to inherit the exception mapping. However results view can be inherited. Please advise ?



As far I see, it works that way from the very beginning. You can always define global-exception-mappings in struts.xml. Also what do you mean by that the "results view can be inherited" ?

@Results/@Result are defined without "@Inherited" meta-annotation so they work the same, they aren't inherited by child classes.





Regards

--

Łukasz

+ 48 606 323 122 http://www.lenart.org.pl/



---------------------------------------------------------------------

To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org<ma...@struts.apache.org>

For additional commands, e-mail: dev-help@struts.apache.org<ma...@struts.apache.org>



CONFIDENTIAL NOTE:
The information contained in this email is intended only for the use of the individual or entity named above and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete the mail. Thank you.

Re: Exception Mapping Annotation seems not inhierted

Posted by Lukasz Lenart <lu...@apache.org>.
2016-07-26 10:14 GMT+02:00 Adrian CHIA <ad...@dbs.com>:
> Hi
>
> It seems that the struts 2.3.4.1 Exception Mapping annotation cannot be inherited by the sub-classes. I attempted to put the annotation in the base class but the child class is unable to inherit the exception mapping. However results view can be inherited. Please advise ?

As far I see, it works that way from the very beginning. You can
always define global-exception-mappings in struts.xml. Also what do
you mean by that the "results view can be inherited" ?
@Results/@Result are defined without "@Inherited" meta-annotation so
they work the same, they aren't inherited by child classes.


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

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


RE: Exception Mapping Annotation seems not inhierted

Posted by Martin Gainty <mg...@hotmail.com>.
possible solution:
declare @Inherited for interface will allow implementor(s) to Inherit the @Inherited interface typehttp://docs.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Inherited.html
How to use @Inherited illustrated athttp://stackoverflow.com/questions/23973107/how-to-use-inherited-annotation-in-java
does this help?
Martin 
______________________________________________ 


> From: adrianc@dbs.com
> To: dev@struts.apache.org
> Subject: Exception Mapping Annotation seems not inhierted
> Date: Tue, 26 Jul 2016 08:14:12 +0000
> 
> Hi
> 
> It seems that the struts 2.3.4.1 Exception Mapping annotation cannot be inherited by the sub-classes. I attempted to put the annotation in the base class but the child class is unable to inherit the exception mapping. However results view can be inherited. Please advise ?
> 
> With regards
> Adrian Chia
> 
> CONFIDENTIAL NOTE:
> The information contained in this email is intended only for the use of the individual or entity named above and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this message in error, please immediately notify the sender and delete the mail. Thank you.