Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class Cast Exception in HttpURLConnection

 
Rahul Juneja
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am executing this line this Line works fine on Windows platform and when we move it to AIX Machine this throws a Class Cast Exception.



The URL We are passing is :


mind it it is "Https" Secured URL.

My Question is How is this Code working fine on Windows machine and if It works Why not on IBM - AIX Machine.

Any Comments or Suggestions Appreciated.

Thanks,
Rahul Juneja
rahulj2k3@yahoo.com
 
Joe Ess
Bartender
Pie
Posts: 9259
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using different virtual machines, probably from different vendors (the windows VM from Sun and the AIX VM from IBM). This line:

breaks your contract with the API because you are claiming to know something about the implementation of the VM which obviously does not hold between platforms. The API states that openConnection returns an instance of URLConnection. You could test connection with the instanceof operator, but you'd still need to provide some processing for the platforms where connection is not an instance of HttpURLConnection.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic