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

I follow the instructions Using the Timer Service to create a simple scheduled run. Trying an automatic approach and using WildFly 8.1.0 Final for it.

Bean Session

@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!"); } } 

When you deploy the class, the message instance >>> Hello Job Created. is correctly created >>> Hello Job Created. , but the sayHello() method is never called.

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

Setting an attribute to an asterisk (*) represents all valid values ​​for the attribute.

Also, only a session with beans state is not allowed for timers, and I use singleton, which is also used in the example.

The bean corporate container timer service allows you schedules for all types of beans enterprise except for a session with beans state.

+6
source share
1 answer

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

the default values ​​for hour and minute are β€œ0”, which can be quite annoying and effectively cause you to set them.

+10
source

Source: https://habr.com/ru/post/970783/


All Articles