+ Start a Discussion

Batch Apex Failure

I'm developing (in a sandbox) an Apex class to perform a mass update of Accounts on our system. Normally when some kind of error occurs during the processing, I receive an e-mail giving me details of the error. However, when the process fails at the start, no such e-mail gets sent so I have no details of what the error is.


Is there any way to get more information about what caused an Apex Batch Job to fail?


The (similified) code I'm trying to execute is:


global class JL_BatchTest implements Database.Batchable<SObject> {

public static void submit() {

JL_BatchTest x = new JL_BatchTest();




private String soqlQuery = 

'Select' + 

' Id' + 

', Name' + 

' from Account';

global Database.QueryLocator start(Database.BatchableContext bc) {

return Database.getQueryLocator(soqlQuery);


global void execute(Database.BatchableContext bc, List<SObject> sObjects) {

processList((List<Account>) sObjects);


global void finish(Database.BatchableContext bc) {


private void processList(List<Account> acs) {

System.Debug('acs.size() = ' + acs.size());

for (Account ac: acs) {

// Do something with each account






Is there anything wrong in this code? I suspect it may be failing at the start because the number of Accounts returned by the query is very high (474,000 on our system), but my understanding is that Batch Apex should be able to handle such numbers of records and, indeed, much higher numbers up to 50 million records (?).


The same class runs without error on a smaller sandbox  which contains just 10 Accounts.


Thanks in advance




Hi John,

not sure if you still need a solution, but just using the Apex Debug Log worked for me. It contains also the batch apex errors.




I also had a hard time trouble shooting why my batch APEX was failing.  The Debug log would always exceed the maximum size for me to see what was causing it to fail.


For troubleshooting, you may want to look into if you have any validation rules in your Account object that may be tripped off by the changes you are making during the batch.