|
Hi, everyone. This is a solution to a problem that I’ve
seen a lot of people have with Axis, especially people just starting out with
it, who have not yet gone through “the pain”J “Oh the pain, the pain...” - Dr.
Smith on the old TV series “Lost In Space”. Anyway, back to
reality.... Google “userException
InvocationTargetException hostname axis” and you’ll see what I
mean. A lot of questions on this exception pattern without an answer. Anyway, since I found the answer (an
answer?), I thought I’d post it for the group. Probably belongs in
some kind of FAQ for Axis if you agree. (Is there such?) Here is the symptom you will see in your
axis response: <?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.lang.reflect.InvocationTargetException</faultstring>
<detail>
<ns1:hostname
xmlns:ns1="http://xml.apache.org/axis/">DEVED01</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body> </soapenv:Envelope> Key parts of the symptom pattern are: (1) InvocationTargetException and (2) The hostname is returned in the detail (and that’s about
all). The essential problem is that Axis doesn’t
give you a clue as to what is the underlying problem (as several people have
reported). What’s worse is that it appears to me that Axis is
swallowing the underlying error, since you have to actively trap it in your
code in order to see it. Specifically... The way to find the underlying error is to
add a catch for Throwable around the point where your server-side code first
starts running. (If you just catch Exception, Axis will still swallow
many of the common errors, and you’re still left clueless.) Just beneath
your catch, you can, of course, add a printStackTrace and whatever other debug
info you would like for your app server (Tomcat in my case) to spit out to the
stdout (standard output) log (catalina.out or log4j log or whatever). Example: In your generated <whatever>SOAPBindingImpl.java,
method, hand-modify it like so: try
{ //Your
app logic }
catch (Throwable e) { /* *
Note: This is last-ditch attempt to catch anything throwable, *
since Axis is apparently swallowing exceptions and not reporting them. */ e.printStackTrace(); } Ben This e-mail message may contain confidential and/or privileged information. If you are not an addressee or otherwise authorized to receive this message, you should not use, copy, disclose or take any action based on this e-mail or any information contained in the message. If you have received this material in error, please advise the sender immediately by reply e-mail and delete this message. Thank you. |
- A Solution to the Ubiquitious InvocationTargetException Ben Ethridge
