+ Start a Discussion
Jai Kumar GuptaJai Kumar Gupta 

Why Apex batch job is failed

I ran a batch job on our sandbox environment for 2.3M records. There were around 11K batches to process. The process got failed in between after processing half of the batches.

User-added image

There were 51 batch failures because of "First error: Ending position out of bounds: 5"." issue but the process stopped with status failed after processing 5K batches.

What could be the possible  reason behind this failure ? Any help would be greatly appreciated.

Grazitti TeamGrazitti Team
Hi Jai,

Here link showing detail of error you are facing and also the method to solve it : http://help.salesforce.com/apex/HTViewSolution?id=000181121&language=en_US

Please refer to the debug log for more information on error.

Looks like you have either an list that you are traversing using index or probably using a substring method where the end of substring that you are specifying is more than the string size
Jai Kumar GuptaJai Kumar Gupta
Thanks for your response. I understand the error message and reason behind that but I don't think this could be a reason of Complete Job failure. It happens when error occurs in the batch then that particular batch gets failed but the process keeps on running and gets completed with status "completed" and does not stop in between.

For ex:
User-added image

This job do have some batch failures but the process did run for all the batches and overall status of the job is completed. But for above batch job it stopped without processing all the batches.

I want to understand why that job got failed without processing all the batches. Hope this clarifies what I'm looking for.