Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java EE 7 Automatic Timer (EJB Timer) not working for WildFly 8.1.0

I am following the Using the Timer Service tutorial to build a simple scheduled execution. Trying the automatic approach and using WildFly 8.1.0 Final for it.

Session Bean

@Singleton
@Startup
public class HelloJob {

    private static final Logger logger = Logger.getLogger(HelloJob.class);

    public HelloJob() {
        logger.error(">>> Hello Job Created.");
    }

    @Schedule(second="*")
    public void sayHello() {
        logger.error(">>> Server Hello!");
    }

}

On deploy the class is properly instantiated printing the >>> Hello Job Created. message, but the method sayHello() is never called.

According to the tutorial the @Schedule(second="*") means that it should execute every second.

Setting an attribute to an asterisk symbol (*) represents all allowable values for the attribute.

Also only stateful session beans are not allowed for timers, and I am using a singleton, which is also used in the example.

The timer service of the enterprise bean container enables you to schedule timed notifications for all types of enterprise beans except for stateful session beans.

like image 315
Evandro Pomatti Avatar asked Jun 12 '14 22:06

Evandro Pomatti


1 Answers

Use @Schedule(second="*", minute="*", hour="*").

the default values for hour and minute are "0" which can be quite irritating and effectively forces you to set these.

like image 180
Max Fichtelmann Avatar answered Oct 01 '22 16:10

Max Fichtelmann