• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassCastException

 
Ajay Chawla
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic