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.

4
  • 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? Commented Jan 4, 2014 at 13:17
  • What do the Debug Logs say when you schedule the class? Does your public static Id myMethod() need to be global? Commented Jan 4, 2014 at 13:33
  • mymethod() is called internally from the finish() method of MyBatch.cls. There is no job seen in ApexJob List.
    – Sonal
    Commented Jan 6, 2014 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
    Commented Jan 6, 2014 at 5:05

1 Answer 1

1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .