[SalesForce] Unable to query CronJobDetail.Name from CronTrigger in Apex

I have been implementing Dan Appleman's solutions since his appearances at Dreamforce, and am currently working with his Going Asynchronous solution and running into a snag. I put a partial solution in place, but have (not infrequently) run into the problem of trying to kick off a batch when there are already too many (5) batches running.

My eclipse version is Kepler, with the most recent Force.com IDE (API version 30.0, at any rate).

In anonymous apex I can write:

List<CronTrigger> jobs = [Select Id, CronJobDetail.Name, State, NextFireTime From CronTrigger limit 10];
// This part is just for reference purposes, clearly, and I am getting results back
for(CronTrigger job : jobs) {
    System.debug(job);
}

without a problem (from his StartScheduler() method, Chapter 7). When I try to put the same query into my class, however, I get the following error:

Save error: No such relation 'CronJobDetail' on entity 'CronTrigger'. If you are attempting <blah blah blah>...

The remaining code, which should tell me if the job has already been scheduled, is unavailable because the query is disallowed. Here it is for reference:

        if(jobs.size() > 0 && jobs[0].state != 'COMPLETED' && jobs[0].state != 'ERROR' && jobs[0].state != 'DELETED') {
        // The job's already running; is the batch running?
        Set<String> activejobstates = 
          new Set<String> {'Queued', 'Processing', 'Preparing'};

        List<AsyncApexJob> apexjobs = 
          [Select Id, ApexClass.Name
           from   AsyncApexJob
           where  ApexClass.Name = 'AsyncProcessor'
           and    Status in :activejobstates];

        // If the batch is running, quit
        if(apexjobs.size() > 0) return;

        // If it's about to run, quit
        if(DateTime.Now().AddSeconds(60) > jobs[0].NextFireTime) return;    

[I (still) find it odd that the code works anonymously, but not saved to a class.]

Has anyone else run into this problem and/or figured out a solution? Is it an API issue, that I need to back down to previous version to get this through? I need to figure it out, as I have some scheduled jobs that are manually scheduled, and other scheduled jobs that use a truncated version of this ^ process, and they're colliding.

Best Answer

You couldn't access the Job Name until Winter '14 so I suspect it is due to an API version. Double check the API version of the class being saved from Eclipse. You can also use Developer Console to update the API version or make changes to test there.