0

I am new to EJB3 world. I want to create scheduler for file processing in EJB. I tried the following code..

package com.fks.nclp.ejb.scheduler;

import javax.ejb.Schedule;
import javax.ejb.Schedules;
import javax.ejb.Stateless;


@Stateless
public class AutoTimerBean {

    @Schedules(
            {
                @Schedule(second="3",persistent=false)
            }
    )   
    public void executeOnEveryTwoSecond(){
        System.out.println("THIS IS TESTING OF EJB SCHEDULER");
    }
}

And deployed EAR application on GlassFish3.1. As per my requirement the scheduler should be fired at every three seconds.

But its not happening. Any suggestion ??? Thanks, Gunjan.

Gunjan Shah
  • 5,088
  • 16
  • 53
  • 72

1 Answers1

1

Got the solution. In GlassFish server, we have to create EJB timer service from admin console.

Steps are as follow ..

Go to glassFish admin console -> Go to Configurations -> Go to server config -> Go to EJB Container

Here set Timer DataSource = JDBC Default Resource pool. Restart the server.

After adding JDBC default resource pool to Timer DataSource, the scheduler works fine.

Thanks, Gunjan.

Gunjan Shah
  • 5,088
  • 16
  • 53
  • 72