classcastexception

Access Array column in Spark

大兔子大兔子 提交于 2019-11-27 08:44:36
A Spark DataFrame contains a column of type Array[Double]. It throw a ClassCastException exception when I try to get it back in a map() function. The following Scala code generate an exception. case class Dummy( x:Array[Double] ) val df = sqlContext.createDataFrame(Seq(Dummy(Array(1,2,3)))) val s = df.map( r => { val arr:Array[Double] = r.getAs[Array[Double]]("x") arr.sum }) s.foreach(println) The exception is java.lang.ClassCastException: scala.collection.mutable.WrappedArray$ofRef cannot be cast to [D at $iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$iwC$$anonfun$1.apply(<console>:24) at $iwC$$iwC$$iwC

CXF - ClassCastException (SEIStub/ClientProxy)

大兔子大兔子 提交于 2019-11-27 06:54:15
问题 I'm trying to build a client jar file to access a webservice. I'm including the jar in a servlet/war that makes the client webservice calls. I'm getting the following error: INFO: 2011 Apr 14 14:57:32,780 MDT [http-thread-pool-8181(4)] ERROR my.package.ClientServlet - Caught exception java.lang.ClassCastException: com.sun.xml.ws.client.sei.SEIStub cannot be cast to org.apache.cxf.frontend.ClientProxy at org.apache.cxf.frontend.ClientProxy.getClient(ClientProxy.java:93) at my.package.Client.

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

夙愿已清 提交于 2019-11-27 05:32:52
问题 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

hadoop MultipleInputs fails with ClassCastException

China☆狼群 提交于 2019-11-27 04:41:20
问题 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)

Meaning of java.lang.ClassCastException: someClass incompatible with someClass

五迷三道 提交于 2019-11-27 02:04:46
I was experiencing occasional exceptions in XPages application: java.lang.ClassCastException: someClass incompatible with someClass. Both mentioned classes are the same, it is class used as session bean. I was not able to google anything covering my problem. Usual explanation for this was change in design elements, not my case. The XPage application become unusable (pages using session bean someClass) since that moment, until restart of http task, or resave of faces-config.xml. In some cases this is related to other exception: com.ibm.jscript.InterpretException: Script interpreter error, line

can't cast to implemented interface

浪子不回头ぞ 提交于 2019-11-27 01:57:00
i'm very confused... I have a class which directly implements an interface: public class Device implements AutocompleteResult {...} Here is proof that I'm looking at the right variables: Object match = ...; log.debug(match.getClass()); // Outputs 'Device' log.debug(match.getClass().getInterfaces()[0]); // Outputs 'AutocompleteResult' Yet when I try to cast an instance of the class to the interface: AutocompleteResult result = (AutocompleteResult) match; I get a ClassCastException! ClassCastException: Device cannot be cast to AutocompleteResult Also, isAssignableFrom returns false and i'm not

Generics, arrays, and the ClassCastException

时光总嘲笑我的痴心妄想 提交于 2019-11-27 01:52:08
I think there must be something subtle going on here that I don't know about. Consider the following: public class Foo<T> { private T[] a = (T[]) new Object[5]; public Foo() { // Add some elements to a } public T[] getA() { return a; } } Suppose that your main method contains the following: Foo<Double> f = new Foo<Double>(); Double[] d = f.getA(); You will get a CastClassException with the message java.lang.Object cannot be cast to java.lang.Double . Can anyone tell me why? My understanding of ClassCastException is that it is thrown when you try to cast an object to a type that cannot be

Class cast exception to same class on Android

帅比萌擦擦* 提交于 2019-11-27 01:50:43
问题 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

android.app.Application cannot be cast to android.app.Activity

天涯浪子 提交于 2019-11-27 01:18:34
I'm trying to change a LinearLayout from another class, but when i run this code: public class IRC extends PircBot { ArrayList<String> channels; ArrayList<Integer> userCount; ArrayList<String> topics; LinearLayout channelLayout; Context context; public IRC(Context ctx) { this.setName("xxxx"); channels = new ArrayList<String>(); userCount = new ArrayList<Integer>(); topics = new ArrayList<String>(); context = ctx; channelLayout = (LinearLayout) ((Activity) context).findViewById(R.id.channels); } i get a ClassCastException context is the Main activity that extends Activity passed with a

MyClass cannot be cast to java.lang.Comparable: java.lang.ClassCastException

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 23:35:29
问题 I am doing a java project and I got this problem and don't know how to fix it. The classes in my project (simplified): public class Item { private String itemID; private Integer price; public Integer getPrice() { return this.price; } } public class Store { private String storeID; private String address; } public class Stock { private Item item; private Store store; private Integer itemCount; public Integer getInventoryValue() { return this.item.getPrice() * this.itemCount; } } Then I try to