i'm new in JSF and i'm trying to create a method that schedule a simple task. I've created the task below using the annotation "Schedule" from ejb 3.2 and i've created the managed bean with the annotation "ApplicationScoped". Every time I start my server, the builder runs and print the line, but the annotated method is not working. I'm using JSF 2.0, Tomcat 8.0
package br.ifsp.eBlueCard.bean
import java.util.List;
import javax.ejb.Schedule;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import br.ifsp.eBlueCard.entities.ECard;
import br.ifsp.eBlueCard.repository.ECardRepository;
@ManagedBean(eager=true)
@ApplicationScoped
public class TimerEmailBean {
private List<ECard> ecards;
public TimerEmailBean(){
System.out.println("I'm alive.");
}
@Schedule(second="*", minute="*", hour="*")
public void listaECards(){
System.out.println("Hi, me too.");
/*EntityManagerFactory factory = Persistence.createEntityManagerFactory("eBlueCard");
EntityManager manager = factory.createEntityManager();
ECardRepository ecr = new ECardRepository(manager);
try{
this.ecards = ecr.buscaEcardsAtivos();
}catch(Exception e){
System.out.println("VAZIO");
}
if(this.ecards.size() > 0){
for(int i=0;i<ecards.size();i++){
System.out.println(this.ecards.get(i).getCliente().getNome());
}
}else{
System.out.println("VAZIO");
}*/
}
public List<ECard> getEcards() {
return ecards;
}
public void setEcards(List<ECard> ecards) {
this.ecards = ecards;
}
}