classcastexception

Spark 1.6.0 throwing classcast exception in Cluster Mode works fine in local mode

让人想犯罪 __ 提交于 2019-12-08 15:07:52
问题 I am trying simple word-count example on spark in Cluster Mode and Local Mode it works fine in local mode but throwing class cast exception in Cluster Mode here is code snippet... package com.example import com.typesafe.config.ConfigFactory import org.apache.spark.{SparkConf, SparkContext} /** * Created by Rahul Shukla on 20/2/16. */ object SampleFile extends App { val config = ConfigFactory.load() val conf = new SparkConf() .setAppName("WordCount") //.setMaster("spark://ULTP:7077")

How to play audio from server in android

核能气质少年 提交于 2019-12-08 12:22:59
问题 I am getting all audio file list from server to list-view by following code. public class ServerFileList extends Activity { URL urlAudio; ListView mListView; ProgressDialog pDialog; private MediaPlayer mp = new MediaPlayer(); private List<String> myList = new ArrayList<String>(); @Override protected void onCreate(Bundle savedInstanceState) { this.requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentView(R.layout.serverfilelist); mListView = (ListView)

ClassCastException: cannot be cast to android.app.Activity

回眸只為那壹抹淺笑 提交于 2019-12-08 03:17:04
问题 I have a list in a fragment and I want a new activity to start when I press something in that list. I have only tried with my first option but when I try it I get the error: 03-20 15:16:13.017: E/AndroidRuntime(941): Caused by: java.lang.ClassCastException: com.test.test.Algebra cannot be cast to android.app.Activity Here's my fragment class: public class FragmentTest extends SherlockListFragment { String formler[]= { "Algebra", "Aritmetik", "Differential- och integralkalkyl", "Funktioner",

getting java.lang.ClassCastException: class java.lang.String in running a simple MapReduce Program

跟風遠走 提交于 2019-12-07 19:07:44
问题 I am trying to execute a simple MapReduce program, wherein the Map takes the input, splits it in two parts(key=> String and value=>Integer) The reducer sums up the values for a corresponding key I am getting ClassCastException everytime. I am not able to understand, what in the code is causing this error My Code: import java.io.IOException; import java.util.Iterator; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache

Caused by: java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.sql.Date

好久不见. 提交于 2019-12-07 17:47:20
问题 I am getting the below given error for the following code snippets: try { cRows = new CachedRowSetImpl(); while(cRows.next()) { MyClass myClass = new MyClass(); myClass.setPrevDate(cRows.getDate("PREV_DATE")); // In debug mode, the error was throwing when I press Resume from here. } } Error: Caused by: java.lang.ClassCastException: java.sql.Timestamp cannot be cast to java.sql.Date In the database, the datatype for the column is DATE only. I am not able to figure out where the Timestamp is

JDK8 type inference issue

风格不统一 提交于 2019-12-07 07:05:02
问题 I'm trying to run the following code which is compiled fine under JDK8 thanks to type inference: public static <A,B> B convert(A a) { return (B) new CB(); } public static void main(String[] args) { CA a = new CA(); CB b = convert(a); //this runs fine List<CB> bl = Arrays.asList(b); //this also runs fine List<CB> bl1 = Arrays.asList(convert(a)); //ClassCastException here } However, running this throws ClassCastException: CB cannot be cast to [Ljava.lang.Object, but the CB b = convert(a) works

Java: Unchecked cast from X to Y / how to implement castOrNull

跟風遠走 提交于 2019-12-07 02:48:50
问题 I have implemented this function: static <X,Y> Y castOrNull(X obj) { try { return (Y)obj; } catch(ClassCastException e) { return null; } } This gives me the compiler warning: Type safety: Unchecked cast from X to Y Which I don't exactly understand. Isn't the try/catch which I am doing here a check for it? Can I ignore the warning? Will my function work as expected or not? How would I implement it correctly? I also tried with a obj instanceof Y check but that doesn't work because of the way

Communication between Signed Applet and server side Controller

Deadly 提交于 2019-12-06 21:58:28
I have created a signed applet for uploading a file to server. Code is running fine but I want to send that file from applet to server side controller where the code has placed to save that file to server. My SendFile Code in signed Applet: public static void sendFile(String destFileName) throws IOException { String filePrivacy = "Public"; String fileKeyword = "uploadFileDocumentName"; String fileComments = "fileComments"; String fileType = "txt"; String fileFolder = "/Works"; String fileDetails = ""; HttpClient client = new HttpClient(); PostMethod postMethod = new PostMethod( "http:/

No ClassCastException is thrown inside Java generics

社会主义新天地 提交于 2019-12-06 19:27:22
问题 Below is the first Java generics I've ever written : public class MyClass { public static <T> T castToAnotherType(Object param) { T ret = null; try { ret = (T) param; } catch (ClassCastException e) { System.out.print("Exception inside castToAnotherType()"); } return ret; } public static void main(String[] args) { try { String obj = MyClass.castToAnotherType(new Object()); } catch (ClassCastException e) { System.out.print("Exception outside castToAnotherType()"); } } } The result is "Exception

ClassCastException ViewGroup$LayoutParams cannot be cast to ViewPager$LayoutParams

牧云@^-^@ 提交于 2019-12-06 18:31:39
问题 My initial code line is inside the overridden method onGlobalLayout() : img.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 100)); ClassCastException occuring in the overridden method onGlobalLayout() - Error Log: 09-02 14:25:35.326: E/AndroidRuntime(5187): java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.support.v4.view.ViewPager$LayoutParams 09-02 14:25:35.326: E/AndroidRuntime(5187): at android.support.v4.view.ViewPager.onMeasure