J2EE Scheduler Development Guide

Use this guide to learn how to develop your own scheduled tasks.


The scheduler runs a servlet. To add sechduling support to your application, you will need to add the scheduler servlet to a web module of the enterprise application. The schedule is defined in the WEB-INF/schedule.xml file of the web module where the scheduler servlet is defined. See the installation guide for how to configure the scheduler.

Each job in the schedule is called a Task. A task can be implemented by a plain Java class or a Stateless Session EJB.

A task class must have a method called execute(). On a schedule, system invokes the execute() method. This method can throw any exception.

Setup Development Environment

You will need to add the scheduler.jar file to your compiler’s class path.

Java Class Task

To implement a task as a plain Java class, implement the com.webage.scheduler.Task interface and implement the execute() method. For example:

package com.mycom.tasks;

public class TestTask implements  {

public void execute() throws Exception {

You can add the task to the schedule file WEB-INF/schedule.xml as follows.

<!--Execute the Java class every 5 minutes -->

EJB Task

You can also use a Stateless Session Bean as a task. Other EJB types are currently not supported. Follow these instructions to develop a task EJB.

Home Interface

The home interface must extend the com.webage.scheduler.TaskHome interface. For example:

package com.mycom.ejbs;

public interface TestTaskHome extends com.webage.scheduler.TaskHome {

Remote Interface

The remote interface must extend com.webage.scheduler.Task, in addition to the standard javax.ejb.EJBObject interface. For example:

package com.mycom.ejbs;

public interface TestTask extends com.webage.scheduler.Task, javax.ejb.EJBObject {

Bean Class

The bean class must implement the execute() method. For example:

package com.mycom.ejbs;

//Bean implementation class for Enterprise Bean: TestTask
public class TestTaskBean implements javax.ejb.SessionBean {

public void execute() throws Exception {
    System.out.println("*****TestTask EJB:execute()");
//Other methods not shown


Add the EJB task to WEB-INF/schedule.xml as follows:

<!-- Run the EJB task every 10 minutes -->

The “id” attribute contains the JNDI name of the EJB. Only, global JNDI names are supported. Local EJB reference names are not supported.

Error Handling

Java task classes are loaded and EJB tasks are created upon the startup of the scheduler servlet. In case of an error, system prints an error message in the stdout and the scheduler is shutdown.

During a task execution, the execute() method can throw any exception. System prints the stack trace in stdout.