java.lang.StringIndexOutOfBoundsException: String index out of range: 1

0 votes

Hi,

I am getting an error in Spark. I tried to use groupByKey() function in scala. But it shows the below error.

ERROR executor.Executor: Exception in task 0.0 in stage 12.0 (TID 28)
java.lang.StringIndexOutOfBoundsException: String index out of range: 1

Can anyone tell me the reason?
Thank You
 

Jan 29 in Apache Spark by akhtar
• 10,330 points
732 views

2 answers to this question.

0 votes

Hi@akhtar,

I also faced this same problem. For my case I used map instead of flatMap. In flatMap each input item can be mapped to or more output items. So, you can try map in place of flatMap.

Thank You

answered Jan 31 by MD
• 22,520 points
0 votes

When using the Java substring() method, a subset of the character sequence can be extracted from a string. The substring index must be any value from 0 to the length of a string. The java.lang.StringIndexOutOfBoundsException thrown by String methods to indicate that the beginIndex is negative , or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex. 

How to solve the StringIndexOutOfBoundsException

  • Check the length of the string before using substring()
  • Exception handling using try...catch.

answered Mar 13 by evanbung
• 180 points

Related Questions In Apache Spark

+1 vote
1 answer

Facing out-of-memory errors in Spark driver

I am guessing that the configuration set ...READ MORE

answered Feb 22, 2019 in Apache Spark by Rishab
95 views
0 votes
1 answer
0 votes
1 answer

Spark error: Caused by: java.lang.RuntimeException: The root scratch dir: /tmp/hive on HDFS should be writable.

Give  read-write permissions to  C:\tmp\hive folder Cd to winutils bin folder ...READ MORE

answered Jul 11, 2019 in Apache Spark by Rajiv
1,618 views
0 votes
0 answers
+1 vote
2 answers
+1 vote
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,920 points
5,072 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,920 points
723 views
+1 vote
11 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyF ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
29,982 views
0 votes
1 answer

Caused by: java.lang.NumberFormatException: Empty String

Hi@akhtar, As we know text files are in ...READ MORE

answered Jan 31 in Apache Spark by MD
• 22,520 points
152 views
0 votes
1 answer

"java.lang.ClassNotFoundException" in Spark on Amazon EMR

Hi@akhtar, In /etc/spark/conf/spark-defaults.conf, append the path of your custom ...READ MORE

answered Apr 29 in Apache Spark by MD
• 22,520 points
54 views