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, 2020 in Apache Spark by akhtar
• 38,260 points
7,640 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, 2020 by MD
• 95,460 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, 2020 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 23, 2019 in Apache Spark by Rishab
1,821 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
7,710 views
–1 vote
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
• 11,380 points
11,028 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
• 11,380 points
2,535 views
+2 votes
11 answers

hadoop fs -put command?

Hi, You can create one directory in HDFS ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
108,830 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, 2020 in Apache Spark by MD
• 95,460 points
4,827 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, 2020 in Apache Spark by MD
• 95,460 points
3,696 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP