I'm trying to implement a batch upload job in my app running on Wildfly 10. I want to create a Quartz job that will download some files and load them in the database. However when my job runs the entitymanager is always null. How can I get my entity manger injected in this case? I wrote the following code that simplifies my situation as much as possible. Can anyone tell me where I've gone wrong?
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
@Stateless
public class DownloadService implements Job {
@PersistenceContext
private EntityManager entityManager;
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
if (entityManager == null) {
System.out.println("############## entityManager is null ####");
} else
System.out.println("************** WORKING ***************");
}
}