Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

determine the root exception?

Tags:

java

exception

for the given exception stack, how the root exception (say it is UnknownHostException ) could be gained?

 [java] org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: Couldn't send message.
 [java] org.codehaus.xfire.fault.XFireFault: Couldn't send message.
 [java]     at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
 [java]     at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:30)
 [java]     at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
 [java]     at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
 [java]     at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:114)
 [java]     at org.codehaus.xfire.client.Client.invoke(Client.java:336)
 [java]     at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
 [java]     at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
 [java]     at $Proxy12.findICPInfoToObject(Unknown Source)
 [java]     at com.sinoi.icp.impl.ICPInfoFinderImpl.findByDomainName(Unknown Source)
 [java]     at com.sinoi.icp.IcpFinderDemo.main(Unknown Source)
 [java] Caused by: org.codehaus.xfire.XFireException: Couldn't send message.
 [java]     at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:145)
 [java]     at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
 [java]     at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
 [java]     ... 9 more
 [java] Caused by: java.net.UnknownHostException: icpinfo.137.300.cn
 [java]     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
 [java]     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
 [java]     at java.net.Socket.connect(Socket.java:529)
 [java]     at java.net.Socket.connect(Socket.java:478)
 [java]     at java.net.Socket.<init>(Socket.java:375)
 [java]     at java.net.Socket.<init>(Socket.java:249)
 [java]     at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:80)
 [java] 
 [java]     at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:122)
 [java] 
 [java]     at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
like image 779
rmn190 Avatar asked Dec 02 '22 01:12

rmn190


1 Answers

Here's a sample method to do it:

public static Throwable getRoot(Throwable t) {
    Throwable result = t;

    while (result.getCause() != null) {
        result = result.getCause();
    }

    return result;
}
like image 72
Maurício Linhares Avatar answered Dec 24 '22 03:12

Maurício Linhares