
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good point rnathan2020! thanks
