You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Richard Gruet (JIRA)" <ji...@apache.org> on 2006/12/09 17:42:20 UTC

[jira] Created: (AXIS2-1853) AxisFault.makeFault() modification required to unwrap Proxy-raised UndeclaredThrowableExceptions.

AxisFault.makeFault() modification required to unwrap Proxy-raised UndeclaredThrowableExceptions.
-------------------------------------------------------------------------------------------------

                 Key: AXIS2-1853
                 URL: http://issues.apache.org/jira/browse/AXIS2-1853
             Project: Apache Axis 2.0 (Axis2)
          Issue Type: Improvement
          Components: kernel
    Affects Versions: 1.1
         Environment: OS Independent
            Reporter: Richard Gruet


PROBLEM:
When a WS implementation throws an Exception which is not "official", i.e. NOT declared in the WSDL for the operation and therefore not declared as an Exception thrown by the operation in the SEI, it is caught by the MessageReceiver generated by Axis2 for the service (in my case an AbstractInOutSyncMessageReceiver), and the static method AxisFault.makeFault() is called to "wrap" the exception into a legal AxisFault :
        ...
        catch (Exception e) {
        throw org.apache.axis2.AxisFault.makeFault(e);
        }

The method AxisFault.makeFault() handles specially InvocationTargetException instances so to "unwrap" them: 
    
    public static AxisFault makeFault(Exception e) {
        if (e instanceof InvocationTargetException) {
            Throwable t = ((InvocationTargetException) e).getTargetException();

            if (t instanceof Exception) {
                e = (Exception) t;
            }
        }
        ...

But another category of "wrapped" exceptions exist, which is not handled by this method: exceptions of class UndeclaredThrowableException, returned by method invoke() of the [java.lang.reflect.]InvocationHandler of a [java.lang.reflect.]Proxy. The wrapped exception is available by calling method getCause() on the UndeclaredThrowableException instance.
So when the WS implementation is a Proxy and an "unofficial" exception is thrown, makeFault() doesn't accurately reflects the target exception and the resulting SOAP fault is not helpful since it justs says "UndeclaredThrowableException" as the cause of the fault.

SUGGESTED SOLUTION:
The solution is very easy to implement and backward compatible: just add a paragraph in AxisFault.makeFault() to handle the case:
        
        ...
        else if (e instanceof UndeclaredThrowableException) {
            Throwable t = ((UndeclaredThrowableException) e).getCause();

            if (t instanceof Exception) {
                e = (Exception) t;
            }
        }

.. So the entire modified makeFault() method would now look like:

    /**
     * Make an AxisFault based on a passed Exception. If the Exception is
     * already an AxisFault, simply use that. Otherwise, wrap it in an
     * AxisFault. If the Exception is an InvocationTargetException or an
     * UndeclaredThrowableException (which already wrap another Exception), get
     * the wrapped Exception out from there and use that instead of the passed
     * one.
     * 
     * @param e
     *            the <code>Exception</code> to build a fault for
     * @return an <code>AxisFault</code> representing <code>e</code>
     */
    public static AxisFault makeFault(Exception e) {
        if (e instanceof InvocationTargetException) {
            Throwable t = ((InvocationTargetException) e).getTargetException();

            if (t instanceof Exception) {
                e = (Exception) t;
            }
        }

        else if (e instanceof UndeclaredThrowableException) {
            Throwable t = ((UndeclaredThrowableException) e).getCause();

            if (t instanceof Exception) {
                e = (Exception) t;
            }
        }

        if (e instanceof AxisFault) {
            return (AxisFault) e;
        }

        return new AxisFault(e);
    }


I personnaly need this modification because I'm using a Proxy implementation in order to perform a number of cross-cutting features, including input parameter validation for which I need to return a significant fault message to the client when parameters are invalid.

Richard

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] Updated: (AXIS2-1853) AxisFault.makeFault() modification required to unwrap Proxy-raised UndeclaredThrowableExceptions.

Posted by "Davanum Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-1853?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Davanum Srinivas updated AXIS2-1853:
------------------------------------

    Assignee: Deepal Jayasinghe

> AxisFault.makeFault() modification required to unwrap Proxy-raised UndeclaredThrowableExceptions.
> -------------------------------------------------------------------------------------------------
>
>                 Key: AXIS2-1853
>                 URL: https://issues.apache.org/jira/browse/AXIS2-1853
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Improvement
>          Components: kernel
>    Affects Versions: 1.1
>         Environment: OS Independent
>            Reporter: Richard Gruet
>         Assigned To: Deepal Jayasinghe
>
> PROBLEM:
> When a WS implementation throws an Exception which is not "official", i.e. NOT declared in the WSDL for the operation and therefore not declared as an Exception thrown by the operation in the SEI, it is caught by the MessageReceiver generated by Axis2 for the service (in my case an AbstractInOutSyncMessageReceiver), and the static method AxisFault.makeFault() is called to "wrap" the exception into a legal AxisFault :
>         ...
>         catch (Exception e) {
>         throw org.apache.axis2.AxisFault.makeFault(e);
>         }
> The method AxisFault.makeFault() handles specially InvocationTargetException instances so to "unwrap" them: 
>     
>     public static AxisFault makeFault(Exception e) {
>         if (e instanceof InvocationTargetException) {
>             Throwable t = ((InvocationTargetException) e).getTargetException();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         ...
> But another category of "wrapped" exceptions exist, which is not handled by this method: exceptions of class UndeclaredThrowableException, returned by method invoke() of the [java.lang.reflect.]InvocationHandler of a [java.lang.reflect.]Proxy. The wrapped exception is available by calling method getCause() on the UndeclaredThrowableException instance.
> So when the WS implementation is a Proxy and an "unofficial" exception is thrown, makeFault() doesn't accurately reflects the target exception and the resulting SOAP fault is not helpful since it justs says "UndeclaredThrowableException" as the cause of the fault.
> SUGGESTED SOLUTION:
> The solution is very easy to implement and backward compatible: just add a paragraph in AxisFault.makeFault() to handle the case:
>         
>         ...
>         else if (e instanceof UndeclaredThrowableException) {
>             Throwable t = ((UndeclaredThrowableException) e).getCause();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
> .. So the entire modified makeFault() method would now look like:
>     /**
>      * Make an AxisFault based on a passed Exception. If the Exception is
>      * already an AxisFault, simply use that. Otherwise, wrap it in an
>      * AxisFault. If the Exception is an InvocationTargetException or an
>      * UndeclaredThrowableException (which already wrap another Exception), get
>      * the wrapped Exception out from there and use that instead of the passed
>      * one.
>      * 
>      * @param e
>      *            the <code>Exception</code> to build a fault for
>      * @return an <code>AxisFault</code> representing <code>e</code>
>      */
>     public static AxisFault makeFault(Exception e) {
>         if (e instanceof InvocationTargetException) {
>             Throwable t = ((InvocationTargetException) e).getTargetException();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         else if (e instanceof UndeclaredThrowableException) {
>             Throwable t = ((UndeclaredThrowableException) e).getCause();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         if (e instanceof AxisFault) {
>             return (AxisFault) e;
>         }
>         return new AxisFault(e);
>     }
> I personnaly need this modification because I'm using a Proxy implementation in order to perform a number of cross-cutting features, including input parameter validation for which I need to return a significant fault message to the client when parameters are invalid.
> Richard

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (AXIS2-1853) AxisFault.makeFault() modification required to unwrap Proxy-raised UndeclaredThrowableExceptions.

Posted by "Davanum Srinivas (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-1853?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Davanum Srinivas resolved AXIS2-1853.
-------------------------------------

    Resolution: Fixed

> AxisFault.makeFault() modification required to unwrap Proxy-raised UndeclaredThrowableExceptions.
> -------------------------------------------------------------------------------------------------
>
>                 Key: AXIS2-1853
>                 URL: https://issues.apache.org/jira/browse/AXIS2-1853
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Improvement
>          Components: kernel
>    Affects Versions: 1.1
>         Environment: OS Independent
>            Reporter: Richard Gruet
>            Assignee: Deepal Jayasinghe
>
> PROBLEM:
> When a WS implementation throws an Exception which is not "official", i.e. NOT declared in the WSDL for the operation and therefore not declared as an Exception thrown by the operation in the SEI, it is caught by the MessageReceiver generated by Axis2 for the service (in my case an AbstractInOutSyncMessageReceiver), and the static method AxisFault.makeFault() is called to "wrap" the exception into a legal AxisFault :
>         ...
>         catch (Exception e) {
>         throw org.apache.axis2.AxisFault.makeFault(e);
>         }
> The method AxisFault.makeFault() handles specially InvocationTargetException instances so to "unwrap" them: 
>     
>     public static AxisFault makeFault(Exception e) {
>         if (e instanceof InvocationTargetException) {
>             Throwable t = ((InvocationTargetException) e).getTargetException();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         ...
> But another category of "wrapped" exceptions exist, which is not handled by this method: exceptions of class UndeclaredThrowableException, returned by method invoke() of the [java.lang.reflect.]InvocationHandler of a [java.lang.reflect.]Proxy. The wrapped exception is available by calling method getCause() on the UndeclaredThrowableException instance.
> So when the WS implementation is a Proxy and an "unofficial" exception is thrown, makeFault() doesn't accurately reflects the target exception and the resulting SOAP fault is not helpful since it justs says "UndeclaredThrowableException" as the cause of the fault.
> SUGGESTED SOLUTION:
> The solution is very easy to implement and backward compatible: just add a paragraph in AxisFault.makeFault() to handle the case:
>         
>         ...
>         else if (e instanceof UndeclaredThrowableException) {
>             Throwable t = ((UndeclaredThrowableException) e).getCause();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
> .. So the entire modified makeFault() method would now look like:
>     /**
>      * Make an AxisFault based on a passed Exception. If the Exception is
>      * already an AxisFault, simply use that. Otherwise, wrap it in an
>      * AxisFault. If the Exception is an InvocationTargetException or an
>      * UndeclaredThrowableException (which already wrap another Exception), get
>      * the wrapped Exception out from there and use that instead of the passed
>      * one.
>      * 
>      * @param e
>      *            the <code>Exception</code> to build a fault for
>      * @return an <code>AxisFault</code> representing <code>e</code>
>      */
>     public static AxisFault makeFault(Exception e) {
>         if (e instanceof InvocationTargetException) {
>             Throwable t = ((InvocationTargetException) e).getTargetException();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         else if (e instanceof UndeclaredThrowableException) {
>             Throwable t = ((UndeclaredThrowableException) e).getCause();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         if (e instanceof AxisFault) {
>             return (AxisFault) e;
>         }
>         return new AxisFault(e);
>     }
> I personnaly need this modification because I'm using a Proxy implementation in order to perform a number of cross-cutting features, including input parameter validation for which I need to return a significant fault message to the client when parameters are invalid.
> Richard

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (AXIS2-1853) AxisFault.makeFault() modification required to unwrap Proxy-raised UndeclaredThrowableExceptions.

Posted by "Richard Gruet (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-1853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12491454 ] 

Richard Gruet commented on AXIS2-1853:
--------------------------------------

Well, it has been almost 5 months since I reported on this issue and apparently nothing has been done yet to integrate the small change that I suggest, nor to reject it. I have been waiting for new releases in hope they would integrate the change, but apparently it has sort of fallen in a black hole. It obliges me to patch every new release of Axis2, which I don't like by principle.

I may be wrong, but this change seems to me pretty harmless and very easy to do, while it handles one case which had been forgotten. I hope you will eventually consider integrating the change, or at least let me know your objections, if any.

Regards

Richard

> AxisFault.makeFault() modification required to unwrap Proxy-raised UndeclaredThrowableExceptions.
> -------------------------------------------------------------------------------------------------
>
>                 Key: AXIS2-1853
>                 URL: https://issues.apache.org/jira/browse/AXIS2-1853
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Improvement
>          Components: kernel
>    Affects Versions: 1.1
>         Environment: OS Independent
>            Reporter: Richard Gruet
>         Assigned To: Deepal Jayasinghe
>
> PROBLEM:
> When a WS implementation throws an Exception which is not "official", i.e. NOT declared in the WSDL for the operation and therefore not declared as an Exception thrown by the operation in the SEI, it is caught by the MessageReceiver generated by Axis2 for the service (in my case an AbstractInOutSyncMessageReceiver), and the static method AxisFault.makeFault() is called to "wrap" the exception into a legal AxisFault :
>         ...
>         catch (Exception e) {
>         throw org.apache.axis2.AxisFault.makeFault(e);
>         }
> The method AxisFault.makeFault() handles specially InvocationTargetException instances so to "unwrap" them: 
>     
>     public static AxisFault makeFault(Exception e) {
>         if (e instanceof InvocationTargetException) {
>             Throwable t = ((InvocationTargetException) e).getTargetException();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         ...
> But another category of "wrapped" exceptions exist, which is not handled by this method: exceptions of class UndeclaredThrowableException, returned by method invoke() of the [java.lang.reflect.]InvocationHandler of a [java.lang.reflect.]Proxy. The wrapped exception is available by calling method getCause() on the UndeclaredThrowableException instance.
> So when the WS implementation is a Proxy and an "unofficial" exception is thrown, makeFault() doesn't accurately reflects the target exception and the resulting SOAP fault is not helpful since it justs says "UndeclaredThrowableException" as the cause of the fault.
> SUGGESTED SOLUTION:
> The solution is very easy to implement and backward compatible: just add a paragraph in AxisFault.makeFault() to handle the case:
>         
>         ...
>         else if (e instanceof UndeclaredThrowableException) {
>             Throwable t = ((UndeclaredThrowableException) e).getCause();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
> .. So the entire modified makeFault() method would now look like:
>     /**
>      * Make an AxisFault based on a passed Exception. If the Exception is
>      * already an AxisFault, simply use that. Otherwise, wrap it in an
>      * AxisFault. If the Exception is an InvocationTargetException or an
>      * UndeclaredThrowableException (which already wrap another Exception), get
>      * the wrapped Exception out from there and use that instead of the passed
>      * one.
>      * 
>      * @param e
>      *            the <code>Exception</code> to build a fault for
>      * @return an <code>AxisFault</code> representing <code>e</code>
>      */
>     public static AxisFault makeFault(Exception e) {
>         if (e instanceof InvocationTargetException) {
>             Throwable t = ((InvocationTargetException) e).getTargetException();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         else if (e instanceof UndeclaredThrowableException) {
>             Throwable t = ((UndeclaredThrowableException) e).getCause();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         if (e instanceof AxisFault) {
>             return (AxisFault) e;
>         }
>         return new AxisFault(e);
>     }
> I personnaly need this modification because I'm using a Proxy implementation in order to perform a number of cross-cutting features, including input parameter validation for which I need to return a significant fault message to the client when parameters are invalid.
> Richard

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (AXIS2-1853) AxisFault.makeFault() modification required to unwrap Proxy-raised UndeclaredThrowableExceptions.

Posted by "Davanum Srinivas (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-1853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12508987 ] 

Davanum Srinivas commented on AXIS2-1853:
-----------------------------------------

Really sorry about the delay. fix is in svn revision 551753

> AxisFault.makeFault() modification required to unwrap Proxy-raised UndeclaredThrowableExceptions.
> -------------------------------------------------------------------------------------------------
>
>                 Key: AXIS2-1853
>                 URL: https://issues.apache.org/jira/browse/AXIS2-1853
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Improvement
>          Components: kernel
>    Affects Versions: 1.1
>         Environment: OS Independent
>            Reporter: Richard Gruet
>            Assignee: Deepal Jayasinghe
>
> PROBLEM:
> When a WS implementation throws an Exception which is not "official", i.e. NOT declared in the WSDL for the operation and therefore not declared as an Exception thrown by the operation in the SEI, it is caught by the MessageReceiver generated by Axis2 for the service (in my case an AbstractInOutSyncMessageReceiver), and the static method AxisFault.makeFault() is called to "wrap" the exception into a legal AxisFault :
>         ...
>         catch (Exception e) {
>         throw org.apache.axis2.AxisFault.makeFault(e);
>         }
> The method AxisFault.makeFault() handles specially InvocationTargetException instances so to "unwrap" them: 
>     
>     public static AxisFault makeFault(Exception e) {
>         if (e instanceof InvocationTargetException) {
>             Throwable t = ((InvocationTargetException) e).getTargetException();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         ...
> But another category of "wrapped" exceptions exist, which is not handled by this method: exceptions of class UndeclaredThrowableException, returned by method invoke() of the [java.lang.reflect.]InvocationHandler of a [java.lang.reflect.]Proxy. The wrapped exception is available by calling method getCause() on the UndeclaredThrowableException instance.
> So when the WS implementation is a Proxy and an "unofficial" exception is thrown, makeFault() doesn't accurately reflects the target exception and the resulting SOAP fault is not helpful since it justs says "UndeclaredThrowableException" as the cause of the fault.
> SUGGESTED SOLUTION:
> The solution is very easy to implement and backward compatible: just add a paragraph in AxisFault.makeFault() to handle the case:
>         
>         ...
>         else if (e instanceof UndeclaredThrowableException) {
>             Throwable t = ((UndeclaredThrowableException) e).getCause();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
> .. So the entire modified makeFault() method would now look like:
>     /**
>      * Make an AxisFault based on a passed Exception. If the Exception is
>      * already an AxisFault, simply use that. Otherwise, wrap it in an
>      * AxisFault. If the Exception is an InvocationTargetException or an
>      * UndeclaredThrowableException (which already wrap another Exception), get
>      * the wrapped Exception out from there and use that instead of the passed
>      * one.
>      * 
>      * @param e
>      *            the <code>Exception</code> to build a fault for
>      * @return an <code>AxisFault</code> representing <code>e</code>
>      */
>     public static AxisFault makeFault(Exception e) {
>         if (e instanceof InvocationTargetException) {
>             Throwable t = ((InvocationTargetException) e).getTargetException();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         else if (e instanceof UndeclaredThrowableException) {
>             Throwable t = ((UndeclaredThrowableException) e).getCause();
>             if (t instanceof Exception) {
>                 e = (Exception) t;
>             }
>         }
>         if (e instanceof AxisFault) {
>             return (AxisFault) e;
>         }
>         return new AxisFault(e);
>     }
> I personnaly need this modification because I'm using a Proxy implementation in order to perform a number of cross-cutting features, including input parameter validation for which I need to return a significant fault message to the client when parameters are invalid.
> Richard

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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