*
The moose likes Servlets and the fly likes ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "ClassCastException" Watch "ClassCastException" New topic
Author

ClassCastException

Ajay Chawla
Greenhorn

Joined: Jan 14, 2004
Posts: 11
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

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Jan 14, 2004
Posts: 11
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

Joined: Nov 27, 2001
Posts: 1561
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?


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ClassCastException
 
Similar Threads
Problem with cvs
refresh every two minutes in jsp
Synchronization
Class Cast Exception - Please help
implementing pagination