0
votes

My InvocationTargetException prints following when did printStackTrace:


AxisFault
 faultCode: file.could.not.be.created
 faultSubcode: 
 faultString: The File could not be created
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://schemas.xmlsoap.org/soap/envelope/}Fault:file.already.existsFile already exists

The File could not be created
    at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
    at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
    at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)

I would like to retrieve faultcode & faultString from InvocationTargetException: file.already.exists File already exists

how can i do this??

1

1 Answers

1
votes

I am not sure why the the stacktrace looks like this and contains no trace of the actual InvocationFailureException, but I assume the AxisFault is directly wrapped in the InvocationFailureException, and then unwrapping it might help, e.g. like:

    try {
         // here code which throws InvocationFailureException
    } catch (InvocationFailureException e) {
        Throwable rootCause = e.getRootCause();
        if (rootCause instanceof AxisFault) {
            AxisFault axFault = (AxisFault)rootCause;
            // now extract information, e.g. 
            axFault.getFaultDetails();
        }
    }

Maybe you even need to get the root cause recursively if it is not wrapped directly.