Access Array column in Spark

ArrayType is represented in a Row as a scala.collection.mutable.WrappedArray. You can extract it using for example val arr: Seq[Double] = r.getAs[Seq[Double]](“x”) or val i: Int = ??? val arr = r.getSeq[Double](i) or even: import scala.collection.mutable.WrappedArray val arr: WrappedArray[Double] = r.getAs[WrappedArray[Double]](“x”) If DataFrame is relatively thin then pattern matching could be a better approach: import org.apache.spark.sql.Row … Read more

UISelectMany on a List causes java.lang.ClassCastException: java.lang.String cannot be cast to T

Your problem is caused by the following facts: Java generics are compiletime syntactic sugar and completely absent during runtime. EL expressions runs during runtime and not during compiletime. HTTP request parameters are obtained as Strings. Logical consequence is: EL doesn’t see any generic type information. EL doesn’t see a List<Long>, but a List. So, when … Read more

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

Philippe Riand explaned this by email: This class cast happens because the same class had been loaded twice by 2 different class loaders. Thus, from a Java standpoint, they are different and the cast fails. Now, each XPages application is having its own classloader. But this class loader is discarded each time a design change … Read more

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

You are passing the Application Context not the Activity Context with getApplicationContext(); Wherever you are passing it pass this or ActivityName.this instead. Since you are trying to cast the Context you pass (Application not Activity as you thought) to an Activity with (Activity) you get this exception because you can’t cast the Application to Activity … Read more