• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting RunTime Exception classCastException  RSS feed

 
Arif Rizwan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi my name is arif i am getting runtime Exception Saying classCastException
here is my code where i am getting classcastException.


when i run it i am getting following Exception


how can i resolve this problem can any one advice me.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error means that you have an object that is a ModifyDetailsRequestBean, and you try to cast it to a SearchUserResponseBean. This does not work, because the object is really not a SearchUserResponseBean. Note that casting does not automatically convert objects for you - if you have a ModifyDetailsRequestBean, then casting it will not magically convert it to a completely different kind of object such as a SearchUserResponseBean.

Here I see some lines where you get an object from a session attribute, and you try to cast it to a SearchUserResponseBean:

Check to make sure what the object you're getting from the session really is. Where are you setting it? Are you getting the correct object, or are you maybe using the wrong key? Or are you putting a wrong object in the list somewhere else?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!