axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chad Stone" <>
Subject Error log handling: onFault() suggestion in SimpleChain.doVisiting()
Date Mon, 04 Mar 2002 18:18:05 GMT
I wrote a log handler (extending BasicHandler) that traps various info on
the server side of a SOAP request/response.

One of the problems I ran into was that, if an AxisFault is thrown on the
server, I could not get my log handler to spit out any useful information
about the nature of the error.  Of course, I implemented an onFault()
method in the handler, which, although it gets called, does not give me a
way to log the nature of the error.  The problem is that onFault() only has
the MessageContext passed in, and MessageContext does not contain any of
the error information.  I know that I can always use the build-in
class-level log4j stuff in Axis to turn on logging for, say, the
SimpleChain class, but I want complete control over the log file format etc
in a unified fashion, so I prefer to put it right into my CustomLogHandler

Two qusetions:
1) What is the preferred method of solving this problem?
2) Is the following solution (which I implemented and works fine)
reasonable, and if so should it be put into the CVS code of
      I modified so that in doVisiting() where it catches
the AxisFault it populates a new property in MessageContext with the
exception message, prior to calling onFault() on the handlers in the chain.
My handlers can therefore grab this error info when their onFault() methods
are called.  More precisely:

    //  From
    private void doVisiting(MessageContext msgContext,
                            HandlerIterationStrategy visitor) throws
AxisFault {
        int i = 0 ;
        try {
            Enumeration enum = handlers.elements();
            while (enum.hasMoreElements()) {
                visitor.visit((Handler)enum.nextElement(), msgContext);
        } catch( AxisFault f ) {
            // notify fault in reverse order and then rethrow
            log.error( JavaUtils.getMessage("axisFault00"), f );

             msgContext.setProperty("FAULT_MESSAGE", f.getMessage());

            while( --i >= 0 )
                ((Handler) handlers.elementAt( i )).onFault( msgContext );
            throw f;

Any insight is greatly appreciated!
- Chad Stone

View raw message