0

I have a web application (jee7, war, running on Wildfly 10).

The application depends on a jar file containing jpa entities and services used among different projects.

I have added the Deltaspike Scheduler Module according to the documentation to the jar project's pom file, but with @Scheduled annotated Jobs/Runnables don't execute at the desired rate/time, they dont get executed at all.

When I create the same annotated classes in the war/main project, everything works fine.

So is there a way to tell Deltaspike to also take the annotated classes in the jar file into account?

Thomas S.E.
  • 1,528
  • 16
  • 28

1 Answers1

0

I finally figured it out:

While the job:

@Scheduled(cronExpression = "0 0/1 * * * ?")
public class TimeLogger implements Job {

  @Inject
  private Logger logger;

  @Override
  public void execute(JobExecutionContext context) throws JobExecutionException {
    logger.info(new Date().toString());

  }
}

is scheduled when placed in main project, it doesn't get scheduled when in jar file.

To fix this I just had to add scope annotation (@Dependend, @ApplicationScoped, ...).

So my library class now looks like:

@Dependent
@Scheduled(cronExpression = "0 0/1 * * * ?")
public class TimeLogger implements Job {

  @Inject
  private Logger logger;

  @Override
  public void execute(JobExecutionContext context) throws JobExecutionException {
    logger.info(new Date().toString());

  }
}

and works like a charm ;)

Thomas S.E.
  • 1,528
  • 16
  • 28