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

Sharing session attributes of a web service and a servlet within same Tomcat container

I have a servlet where I store a object into attribute storage of ServletContext: @WebServlet(name = "MainTestServlet", urlPatterns = {"/MainTestServlet"}) public class MainTestServlet extends HttpServlet { protected void…
sk2212
  • 1,688
  • 4
  • 23
  • 43
0
votes
2 answers

java mail classcastexception during getcontent

When i am trying to retrieve gmail content through getcontent() method i am getting following exception java.lang.ClassCastException: com.sun.mail.imap.IMAPInpustream cannot be cast to javax.mail.Multipart So I converted the inputsream to string but…
Madhu
  • 298
  • 1
  • 12
0
votes
2 answers

ClassCastException for Filter in Tomcat startup

Im getting an error like this. This is happend when i run the program and it did not run.it showed following error. Jul 10, 2013 1:21:24 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which…
user1758876
  • 1
  • 1
  • 4
0
votes
1 answer

How to save and then load an instace of subclass for a property in hibernate

We have a class User having a one-to-one relationship with a Preference (The property is called storedPreference). Suppose a user where an instance of CustomPreference (a subclass of Preference) is saved as its storedPreference. Getting…
rabolfazl
  • 435
  • 1
  • 8
  • 24
0
votes
3 answers

Applet: visually bugs out only in browser, and throws exception from Swing

We've been struggling here at the office with a seemingly unsolvable bug in one of our (massive) applets, this one being a Java simulation of MS Word, for exam purposes. The exception seems to stem from swing itself, and I'm not sure how I would go…
0
votes
2 answers

Class cast exception cannot be cast to android.app.Fragment

I am not sure why I am getting this class cast exception. I am using support version ListFragment from a FragmentActivity. Below is my Activity package com.thuptencho.transitbus.routes; import java.util.List; import…
Thupten
  • 2,158
  • 1
  • 24
  • 31
0
votes
1 answer

Hibernate id returns clasCastException

I've been given this error: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer at org.hibernate.type.descriptor.java.IntegerTypeDescriptor.unwrap(IntegerTypeDescriptor.java:36) [...] It says me so, because…
Iozan
  • 31
  • 1
  • 9
0
votes
3 answers

ClassCastException with Java's TreeMap when using custom classes as the key

The following code throws a ClassCastException when I try to get a mapping with my custom Dog class as the key: import java.util.TreeMap; public class testMain { public static void main(String[] args) { TreeMap m =…
chessofnerd
  • 1,219
  • 1
  • 20
  • 40
0
votes
2 answers

Getting ClassCastException while accessing list elements individually in java

Below is my code in Java, inside a class named DnsTime: List list = new ArrayList(); String selUrl = "http://www.abc.com"; String query = "select dns_time,update_time from dns_time where url=?"; list =…
user2365917
  • 1,095
  • 5
  • 15
  • 21
0
votes
1 answer

Why the ClassCastException?

Im getting a ClassCastException in on this line. .putStringArrayListExtra("list", (ArrayList) listItems)); I'm trying to send contents of ListView to another Activity. I cant tell why. Can anyone help. private double overallTotalproduct; public…
0
votes
1 answer

Hibernate Projection throwing ClassCastException

Hibernate 3x + Spring MVC 3x PART-1 Generic Method // getAll @SuppressWarnings("unchecked") public List getAll(Class entityClass) throws DataAccessException { Criteria criteria =…
0
votes
2 answers

ClassCastException problems

I was programming a Cert Parser with eclipse, I use my country government departments provide class that it can parser a specialized certificate in my country. But I have little trouble about something, When I compiler my code,the console show these…
user2452153
  • 85
  • 2
  • 2
  • 4
0
votes
2 answers

Retrieving results from query in hibernate not working

I'm still a newbie at Hibernate and am trying to retrieve the results from a simple SELECT query. I keep getting a ClassCastException however. Can anyone tell me what I'm doing wrong here? Here's the code: public Wo getWoById(int id) { Session…
Anubis
  • 1,162
  • 4
  • 14
  • 31
0
votes
1 answer

java.lang.classcastexception:java.util.ArrayList

i am trying to populate a listview from SQLite database but having class cast exception. Here is my logcat: 05-26 09:03:40.376: E/AndroidRuntime(309): Caused by: java.lang.ClassCastException: java.util.ArrayList 05-26 09:03:40.376:…
user2011302
  • 391
  • 1
  • 4
  • 22
0
votes
2 answers

getting java.lang.classCastException:android.os.Bundle

i am trying to show a pic clicked from camera on another activity image view,but getting image out of the bundle into bitmaps.. i get this error. my code is package com.example.iwm; import java.io.File; import…
Yogesh Kumar
  • 682
  • 1
  • 10
  • 29
1 2 3
99
100