3

I have a batch class in which on a specific condition I call system.scheduleBatch().I am passing the instance of the same batch class to system.scheduleBatch().

global class MyBatch implements Database.Batchable<ID>, Database.AllowsCallouts, Database.Stateful{
        //some code
    public static ID myMethod()
    {
        MyBatch myBatchObj = new MyBatch ();  
        if(condition1)
        {
            return System.scheduleBatch(myBatchObj ,'MyBatch', 1, 1);
        }
    }   
 }

When I execute this class via code it works but when this is executed through managed-beta package Schedule job is visible on UI and it is shown started but does not executes. I also tried on released package the result was same.Its only working upon unmanaged package and code.

  • So is MyBatch a class in your managed package and you call yournamespace.MyBatch.myMethod() from outside the package and then it fails? Also, are you seeing anything in your Apex Jobs list? – Phil Hawthorn Jan 4 '14 at 13:17
  • What do the Debug Logs say when you schedule the class? Does your public static Id myMethod() need to be global? – bigassforce Jan 4 '14 at 13:33
  • mymethod() is called internally from the finish() method of MyBatch.cls. There is no job seen in ApexJob List. – Sonal Jan 6 '14 at 5:02
  • The public static method needs not to be global because its called from the same class in which its defined. There is nothing significant in the logs. – Sonal Jan 6 '14 at 5:05
1

There was a Schema.getGlobalDescribe() call in the constructor of MyBatch.cls which was causing the issue. Issue resolved

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.