function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
steve_andersensteve_andersen 

error working with @future: batchable class has jobs pending or in progress

I'm just starting with the @future tag and added a future call to a Contact after insert trigger I've got. I added a call to a method which I plan to have geocode the Contact based on address, via a call out to google's geocoding service.

My method is very simple right now:
Code:
public class dataAugmentation { 
 @future
 public static void augmentAddresses(List<id> contactIdsToAugment) {
  List<Contact> ContactsToBeUpdated = new List<Contact>();
  for (Contact thisContact : [Select Id, OtherStreet,OtherCity,OtherState,OtherPostalCode,OtherCountry from Contact where Id IN :contactIdsToAugment]) { 
    thisContact.OtherCountry='Zanzibar';
    ContactsToBeUpdated.add(thisContact);
  
   //callout to web service
   //thisContactToAugment.Country='Zanzibar';
  }  
  update ContactsToBeUpdated;  
 }
}

 My code compiles and runs in the UI, but the future action (Country updated to 'Zanzibar') hasn't happened after an hour. When I try to modify the class that contains the future method, I get this error in the IDE:

Batchable class has jobs pending or in progress
dataAugmentation.cls
Winter 09 Preview/src/unpackaged/classes
line 1
Force.com save problem

I couldn't find any documentation about how future calls get batched and run, but if I had to interpret this error message I would guess that my updates are sitting in a queue waiting to run, and while that is happening, I can't modify the class.

Is that what is going on? Are there ways to monitor what future calls are waiting for execution?

Thanks,
Steve


Best Answer chosen by Admin (Salesforce Developers) 
LegerdemainLegerdemain

The explanation for the error message ("Batchable class has jobs pending or in progress") is

 

Batch apex classes cannot be changed while there are still batches in the apex queue. You can view this queue under Setup | Administration Setup | Monitoring | Apex Jobs

 

While you have jobs being processed you cannot change the apex class that is handling the active (or pending) processes. You can abort these processes if you need to stop execution of batch jobs.

 

If you dont' have any pending/processing jobs and see this error, then someone in salesforce support would need to investigate.

All Answers

pmorellipmorelli
I'll check on the service that's supposed to be processing those, it might be off in pre-release.
pmorellipmorelli
yup, it's off. There's a bug fix for it to be turned on. I'll see when the next build of prerelease is going out.

there's another wrinkle, the prerelease environment has a more restricted outbound configuration, so your callout might not work.
pmorellipmorelli
next build going out tonight, but I think you may be hit by the proxy restrictions...

let me know...

steve_andersensteve_andersen
Thanks, it's working now.

I'll try to add some callouts and let you know if I get anywhere.

Thanks for looking into it,
Steve
LegerdemainLegerdemain

The explanation for the error message ("Batchable class has jobs pending or in progress") is

 

Batch apex classes cannot be changed while there are still batches in the apex queue. You can view this queue under Setup | Administration Setup | Monitoring | Apex Jobs

 

While you have jobs being processed you cannot change the apex class that is handling the active (or pending) processes. You can abort these processes if you need to stop execution of batch jobs.

 

If you dont' have any pending/processing jobs and see this error, then someone in salesforce support would need to investigate.

This was selected as the best answer