| Author |
IOException thrown where not declared?
|
David Balažic
Ranch Hand
Joined: May 15, 2008
Posts: 83
|
|
Hi!
I got this stack trace:
How can javax.xml.ws.Service.<init> (the constructor protected Service(java.net.URL wsdlDocumentLocation, QName serviceName)) throw an IOException when it does not declare it in a throws clause ?
It is a checked exception that must be declared if thrown, right?
The code in com.fo.bar.FooService.<init>(FooService.java:77) is:
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19232
|
|
|
That's not the stack trace - that's the cause of the stack trace. You can tell by the "caused by". Without seeing the complete stack trace I can't confirm, but I think that this IOException is wrapped into RuntimeException or a subclass of it.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
David Balažic
Ranch Hand
Joined: May 15, 2008
Posts: 83
|
|
The begining is this:
The "Caused by" code is then called somewhere inside the MethodBindingMethodExpressionAdapter.invoke() call.
javax.faces.el.EvaluationException is a RuntimeException, but I don't see why javax.xml.ws code would be creating JSF classes ???
Doesn't the "Caused by" part tell what exception happened originally at what place ?
|
 |
David Balažic
Ranch Hand
Joined: May 15, 2008
Posts: 83
|
|
I also see that the source of the exception:
sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
declares:
public synchronized java.io.InputStream getInputStream() throws java.io.IOException
So to me it seems that an IOException was thrown there (in getInputStream()) and it somehow propagated thru the Service(x,z) constructor which does _not_ declare a throws IOException.
Confused....
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
David, if you see the source of javax.xml.ws.Service class, then you'll see that it calls the javax.xml.ws.spi.Provider.createServiceDelegate to create the service delegate. That method calls some other method and that some other and finally the control reaches to the invoke method of MethodBindingMethodExpressionAdapter class whose invoke method wraps the IOException to EvaluationException as can be seen from this excerpt of the invoke method
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
 |
|
|
subject: IOException thrown where not declared?
|
|
|