Questions tagged [classcastexception]

The Java exception thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance.

ClassCastException is the Java unchecked exception thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance.

FAQ:

  1. Explanation of "ClassCastException" in Java
  2. What else can throw a ClassCastException in java?
1698 questions
0
votes
1 answer

Hitting ClassCastException to String

EDIT : solved using this solution I have a very strange problem. I'm trying to deserialize a HashMap with two classes that have since been changed, though not to any large degree. Can't post code because it's under copyright. Notably the constructor…
tM --
  • 207
  • 1
  • 13
0
votes
1 answer

classcastexpetion when using android:layout_toStartOf

I have a ListView where I until today have positioned two views: One ImageView to the left of its parent, and then I use a TextView positioned just to the right of this ImageView. In xml I use the following code to do…
0
votes
1 answer

Why does ClassCastException not show the class name?

In Java 1.4.2 and earlier versions, if you get a ClassCastException, you can see the exception stack trace but not the class name. If you want to find out the class of the object for which casting failed, you have to debug. Is it still the same in…
b.roth
  • 9,421
  • 8
  • 37
  • 50
0
votes
3 answers

ClassCastException in Filter?

I'm having difficulties in my web app, I post codes and define what im doing in code parts... This is my Filter which checks user type(admin, manager, user).. And im getting error here at line which marked... public void doFilter(ServletRequest…
Pitch
  • 87
  • 1
  • 4
  • 13
0
votes
1 answer

Why there is a ClassCastException when isInstanceOf returns true on a scala type with wildcard parameter?

My questions are: what is this warning about? There is no type parameter for reflect.runtime.universe.TypeRef why this is thrown on method invocation arg rather than asInstanceOf? Console output: Welcome to Scala version 2.10.0 (Java HotSpot(TM)…
Max
  • 2,065
  • 24
  • 20
0
votes
1 answer

Android ClassCastException after reading from SharedPreferences

Yesterday, I built a SettingsActivity for my Android app where the user can enter the URL of a webservice-server. I save this using: editor = sharedPref.edit(); editor.putString( getString(R.string.SAVED_URL_MOBILEHELPER),…
bish
  • 3,381
  • 9
  • 48
  • 69
0
votes
4 answers

Getting a ClassCastException from my iterator next method

I'm using Spring 3.1.0, Hibernate 4, JDK 7, to a Tomcat 7 and getting a ClassCastException on the itr.next() method. The aaData object does contain the data. List aaData = customerlistDaoimpl.getCustomerList(); /* * putting data in a…
user931501
  • 91
  • 3
  • 12
0
votes
0 answers

ClassCastException when retrieving list of enums from database

public class WebUser { @ElementCollection(targetClass = SecurityRole.class) @Enumerated(EnumType.STRING) @CollectionTable(name = "webRole_SecurityRole") @Column(name = "roles") private List securityRoles = new…
HADEV
  • 437
  • 8
  • 19
0
votes
1 answer

File open dialog application stopped unexpectedly

I have written code for file dialog in android and it was working perfect but today when i run code then my application crashes unexpectedly. I have written file dialog application which shows all paths in ListView. My full activity code is as…
user2598157
0
votes
4 answers

Java class cast exception with hibernate criteria query

I am getting java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long exception while executing int totalCount=criteria.list().size();. Please help me to identify the reason and a solution. public GridPageDet…
skmaran.nr.iras
  • 8,152
  • 28
  • 81
  • 116
0
votes
3 answers

Load Class, Generate Object of this class

I'm a beginner at java Reflection/Dynamic Loading. I want to load a specific Class ( that implements an Interface ) from a jar-File. Further more i want to initialize an Object of this Class and cast it to my specific Interface. I tried…
0
votes
1 answer

ClassCast Exception - TextView cannot be cast to EditText

I am facing ClassCast Exception in my EnquireActivity. According to the logcat, I am having ambiguity in id of an EditText and TextView. But I have provided different IDs to both of them. Being a newbie to android I am unable to find out why it is…
divyang7
  • 309
  • 3
  • 10
  • 22
0
votes
1 answer

Suspended while debugging Android with AsyncTask

Here is part of my Activity codes: button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { IParser = new ImageParser(MainActivity.this, EarthqpicUrl); IParser.execute(); …
stsho89
  • 23
  • 1
  • 5
0
votes
4 answers

weird class cast exception

I can't understand why i've got ClassCastException at the last row of code I thought if i had OrgStructure list parametrised - there will be no problem List OrgStructure = null; Query query = null; ... ... …
Sergey
  • 21
  • 7
0
votes
2 answers

ClassCast Exception in activity

i am facing some problems in creating an enquiry form in my android app. The logcat is showing ClassCast error. I am a beginner in android so I don't know how to deal with it. The error is on line 50. protected void onCreate(Bundle…
divyang7
  • 309
  • 3
  • 10
  • 22