Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tJavaFlex java.lang.ArrayIndexOutOfBoundsException

Hi, I'm trying to parse strings into key-value pairs in a tJavaFlex so they can be loaded by tContextLoad in Talend Studio 6.4.1

 

tSubJob - loads a config file and outputs the variables as a string  i.e. "Username;admin;" "Password;123;" etc

|

tJavaFlex - split into key-values

|

tContextLoad - load into environment variables

 

the code in tJavaFlex is 

 

String [] kvPairs = row6.contextString.split(";");
row5.key = kvPairs[0];
row5.value = kvPairs[1];

 

But i get the error below. row6 is definitely the input row and 5 the output. 

 

Exception in component tJavaFlex_1
java.lang.ArrayIndexOutOfBoundsException: 1
at tRunJob_2Process(CreateStressRateInMSS.java:4225)
at tJava_1Process(CreateStressRateInMSS.java:3416)
at runJobInTOS(CreateStressRateInMSS.java:5407)
at main(CreateStressRateInMSS.java:4960)
[FATAL]: tJavaFlex_1 1
java.lang.ArrayIndexOutOfBoundsException: 1
at tRunJob_2Process(CreateStressRateInMSS.java:4225)
at tJava_1Process(CreateStressRateInMSS.java:3416)
at runJobInTOS(CreateStressRateInMSS.java:5407)
at main(CreateStressRateInMSS.java:4960)
[statistics] disconnected

 

Anyone any ideas?

 

Thanks

 

Labels (5)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

This suggests that your String being split does not have a semicolon in it. The java.lang.ArrayIndexOutOfBoundsException exception is a standard Java exception indicating that the array does not have the number of elements you are expecting. Can you just print the value held by row6.contextString in your tJavaFlex....

 

System.out.println(row6.contextString);

View solution in original post

5 Replies
Anonymous
Not applicable
Author

The above is done in the main section of tjavaflex btw
Anonymous
Not applicable
Author

This suggests that your String being split does not have a semicolon in it. The java.lang.ArrayIndexOutOfBoundsException exception is a standard Java exception indicating that the array does not have the number of elements you are expecting. Can you just print the value held by row6.contextString in your tJavaFlex....

 

System.out.println(row6.contextString);
Anonymous
Not applicable
Author

Many thanks rhall when i inspected the output it was a null value for one of the values which was causing the issue. Have managed to fix it now. 

rnathan2020
Contributor
Contributor

Good one. Actually I would enclose this kind of iffy code in try {} catch{} block.
Anonymous
Not applicable
Author

Good point rnathan2020! thanks