• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClassCastException

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
in one of my servlets Iam setting a Vector in request attribute, but when i try to get it in my jsp its giving me an Object which Iam not able to cast to a vector. When I check it using instanceof operator it gives me false for Vector.
Need your help guys...
Ajay
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use o.getClass().getName() to find out what type the Class is.
It is sometimes possible for a single Class to be loaded by two ClassLoaders, and in that case an instance created in CL1 is not equal to a Class created by CL2. This shouldn't be possible with a java.util.Vector though. Requests to load java.* Classes should always be passed to the system ClassLoader so that there is only a single version of the Class used by all code in the JVM.
Try to imagine the concequences of having multiple definitions of java.lang.Object - Go on!
Dave
 
Ajay Chawla
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,
I already tried that, its giving me java.lang.Object.Actually I've a web service deployed on weblogic which returns a custom object.
When my java client gets this object the getter method returns an java.lang.Object, and not a Vector.
it might be possible that Vector might not be supported and it is returned as java.lang.Object only.
iam new to web services so need your views..
Ajay
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ajay Chawla:
Hi David,
I already tried that, its giving me java.lang.Object.Actually I've a web service deployed on weblogic which returns a custom object.
....


hmm.. you're saying that is giving you a java.lang.Object, but then you mention a custom Object? maybe that's the reason you can't cast this custom object to a Vector?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic