JBoss AS 7.1 - execution schedule using @Schedule annotation

Does anyone know how to annotate @Schedule on JBoss AS 7?

I know that on Glassfish-3.1.2 it works out of the box.

I try this:

@ManagedBean @Stateless(name="ImportStatementSchedule") public class ImportStatementSchedule implements Serializable{ private Logger _log = Logger.getLogger(this.getClass()); @Schedule(minute="*") public void executeImport(){ _log.info("Scheduled task started"); } } 

I expect to receive a log message every minute, but nothing;)

I checked these forum topics, but nothing helps:

https://community.jboss.org/message/623574

https://community.jboss.org/message/621893

https://community.jboss.org/message/637567

A have JBoss AS 7.1.1-Final

Perhaps I forgot something, please, can someone point me to the right path?

UPDATE:

I know that JBoss registers EJB in JNDI:

 11:07:05,548 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-6) JNDI bindings for session bean named ImportStatementSchedule in deployment unit deployment "finadv.war" are as follows: java:global/finadv/ImportStatementSchedule!finadv.bean.ImportStatementSchedule java:app/finadv/ImportStatementSchedule!finadv.bean.ImportStatementSchedule java:module/ImportStatementSchedule!finadv.bean.ImportStatementSchedule java:global/finadv/ImportStatementSchedule java:app/finadv/ImportStatementSchedule java:module/ImportStatementSchedule 

UPDATE2

It was resolved as indicated in the comments.

+6
source share
3 answers

A timer service is an EJB service. ImportStatementSchedule must be an @Stateless or @Singleton bean session. From the EJB 3.1 specification, section 18.2:

For auto-generated timers, the timeout method may be a method that is annotated with a Schedule annotation. Timers can be created for a session without beans, singleton session beans, message-driven beans, and 2.1 entity beans. Timers cannot be created for a session with beans state.

The INFO journal operator is misleading. JBoss does not register EJB. It just uses the same naming scheme as defined by the @ManagedBean (Javadoc) annotation:

[..] Managed Bean names must be unique in the Java EE module. For each Managed Bean managed, Java EE containers must provide the following entries in the JNDI using the same naming scheme used for EJB components. In the application namespace:

java:app/<module-name>/<bean-name>

In the module namespace of the module containing the managed Bean:

java:module/<bean-name>

+6
source

I can add that if you write

@Schedule(minute="*")

he will shoot only at midnight. Since the hour parameter has a default value: 0 .

Try: @Schedule(minute = "/1", hour = "") or something like that. In my case, it helped.

+4
source

You must specify the clock , try:

 @Schedule(hour="\*", minute="\*") 
0
source

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


All Articles