Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

IOException thrown where not declared?

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Sheriff
Posts: 21972
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Balažic
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Not so fast naughty spawn! I want you to know about
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic