classcastexception

Class cast exception to same class on Android

孤街醉人 提交于 2019-11-28 07:32:01
I'm having a strange problem with ClassCastException on Android. One class cannot be casted to the same class: java.lang.RuntimeException: Unable to start activity ComponentInfo: java.lang.ClassCastException: com.example.model.BadeWrapper cannot be cast to com.example.model.BadgeWrapper java.lang.ClassCastException: com.example.events.widgets.TouchyWebView cannot be cast to com.example.events.widgets.TouchyWebView java.lang.ClassCastException: com.example.friends.widgets.FriendsTabView cannot be cast to com.example.friends.widgets.FriendsTabView When I find the line with error, all it does is

Why am I getting a ClassCastException when generating javadocs?

纵饮孤独 提交于 2019-11-28 05:39:00
I'm using ant to generate javadocs, but get this exception over and over - why? I'm using JDK version 1.6.0_06 . [javadoc] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc [javadoc] at com.sun.tools.javadoc.AnnotationDescImpl.annotationType(AnnotationDescImpl.java:46) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDocletWriter.getAnnotations(HtmlDocletWriter.java:1739) [javadoc] at com.sun.tools.doclets.formats.html.HtmlDocletWriter.writeAnnotationInfo(HtmlDocletWriter.java:1713) [javadoc] at com.sun.tools.doclets.formats

ClassCastException: RestTemplate returning List<LinkedHashMap> instead of List<MymodelClass>

拟墨画扇 提交于 2019-11-28 05:20:16
I'm trying to access getter methods on my MyModelClass but my code is returning List<LinkedHashMap> instead of List<MyModelClass> . This is my code. List<MyModelClass> myModelClass=(List<MyModelClass>) restTemplate.postForObject(url,mvm,List.class); System.out.println("Response= " + myModelClass); I tried to print the response and I got the JSON Response that I'm expecting. but when I tried to run this code. System.out.println("Response= " + myModelClass.get(0).getMessage()); It will produce this error. java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.XXX.XXX

java.lang.ClassCastException: org.json.simple.JSONArray cannot be cast to org.json.JSONArray

二次信任 提交于 2019-11-28 01:10:50
问题 I need to read a JsonArray data from a file (on an SD card) and store it into a SQLite database. but I am getting a java.lang.ClassCastException: org.json.simple.JSONArray cannot be cast to org.json.JSONArray exception while parsing data to JsonArray . Data in the file is very huge, the whole data can not be stored in a single String or String Buffer or String Builder. Here is my code. FileReader fileReader = new FileReader(file_path); Object obj = jsonParser.parse(fileReader); JSONArray

List to TreeSet conversion produces: “java.lang.ClassCastException: MyClass cannot be cast to java.lang.Comparable”

时间秒杀一切 提交于 2019-11-27 23:42:59
问题 List<MyClass> myclassList = (List<MyClass>) rs.get(); TreeSet<MyClass> myclassSet = new TreeSet<MyClass>(myclassList); I don't understand why this code generates this: java.lang.ClassCastException: MyClass cannot be cast to java.lang.Comparable MyClass does not implement Comparable. I just want to use a Set to filter the unique elements of the List since my List contains unncessary duplicates. 回答1: Does MyClass implements Comparable<MyClass> or anything like that? If not, then that's why. For

hadoop MultipleInputs fails with ClassCastException

ⅰ亾dé卋堺 提交于 2019-11-27 23:34:18
My hadoop version is 1.0.3,when I use multipleinputs, I got this error. java.lang.ClassCastException: org.apache.hadoop.mapreduce.lib.input.TaggedInputSplit cannot be cast to org.apache.hadoop.mapreduce.lib.input.FileSplit at org.myorg.textimage$ImageMapper.setup(textimage.java:80) at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:142) at org.apache.hadoop.mapreduce.lib.input.DelegatingMapper.run(DelegatingMapper.java:55) at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:764) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:370) at org.apache.hadoop.mapred.Child$4.run(Child

Android: ClassCastException when adding a header view to ExpandableListView

微笑、不失礼 提交于 2019-11-27 18:57:39
I'm trying to add a header to an ExpandableListView like so: headerView = View.inflate(this, R.layout.header, null); expandableListView.addHeaderView(headerView); expandableListView.setAdapter(new SectionedAdapter(this)); Which gives me the following error: 12-08 16:23:42.354: ERROR/AndroidRuntime(421): Caused by:java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams 12-08 16:23:42.354: ERROR/AndroidRuntime(421): at android.widget.ListView.clearRecycledState(ListView.java:504) 12-08 16:23:42.354: ERROR/AndroidRuntime(421): at android.widget.ListView.resetList(ListView.java:490)

Why a ClassCastException but not a compilation error?

依然范特西╮ 提交于 2019-11-27 18:50:35
问题 Why don't I get a compilation error in the code below? I get a ClassCastException which is a little confusing. Is it because they are related? class Ink {} Interface Printable {} class ColorInk extends Ink implements Printable {} class BlackInk extends Ink {} class TwistInTaleCasting { public static void main(String args[]) { Printable printable = null; BlackInk blackInk = new BlackInk(); printable = (Printable)blackInk; } } 回答1: Why don't I get a compilation error in the code below? Because

Get All Installed Application icons in Android : java.lang.ClassCastException

怎甘沉沦 提交于 2019-11-27 17:52:03
问题 There is a java.lang.ClassCastException when I am trying to get a installed applications icon. Here is my code. public Bitmap getAppIcon(String path) { PackageInfo pi = pm.getPackageArchiveInfo(path, 0); pi.applicationInfo.sourceDir = path; pi.applicationInfo.publicSourceDir = path; Drawable icon = pi.applicationInfo.loadIcon(pm); Bitmap APKicon = ((BitmapDrawable) icon).getBitmap(); return APKicon; } where, pm is PackageManager pm = getPackageManager(); and the error shown in the LogCat is

readResolve not working ? : an instance of Guava's SerializedForm appears

半城伤御伤魂 提交于 2019-11-27 13:59:40
问题 During deserialization of one of our data structure (using the default mechanism (no custom writeObject/readObject)), an instance of ImmutableMap$SerializedForm (from google's Guava library) shows up. Such an instance should not be visible from clients of guava because instances of SerializedForm are replaced using readResolve (see for example "writeReplace" in class com.google.common.collect.ImmutableMap). Hence deserialization fails with the following message : java.lang.ClassCastException: