I'm developing a web app in java ee and i want to update the weather every x amount of time. This is the code that i want to execute every 20 seconds but it does not start, can someone explain me why? I have to call it somewhere?
@Startup
@Singleton
public class ManageForecast implements Serializable{
private String urlQuery;
private String woeid;
private String cityHome;
private String tempHome;
private List<Location> place;
private Forecast forecast;
@PersistenceContext
EntityManager em;
@Schedule(second = "*/20", minute = "*", hour = "*")
public void updateForecast(){
try {
System.out.println("PARTITO!!!");
place = em.createQuery("select l from Location l").getResultList();
for (Location location : place) {
forecast(location);
}
} catch (Exception e) {
e.printStackTrace();
}
}