views:

489

answers:

3

Hi, I am new to EJB 3 . I use the following code to start endless EJB 3 timer then deploying it on JBOSS 4.2.3

@Stateless
public class SimpleBean  implements SimpleBeanRemote,TimerService  {

@Resource
TimerService timerService;
private Timer timer ;
@Timeout
public void timeout(Timer timer) {
    System.out.println("Hello EJB");

 }
}

then calling it

  timer = timerService.createTimer(10,  5000, null);

It works well. I created a client class that calls a method that creates the timer and a method that is called when the timer times out.

I forget to call cancel then it does not stop .redeploy with cancel call never stop it. restart Jboss 4.2.3 never stop it. How I can stop EJB timer ? Thanks for helping.

A: 

I've resolved it. thanks myself :)

worldpython
If someone stumbles on this, it would be nice if you could provide an answer. Also, mark the question as answered.Cheers!
Tomas
sorry Tomas, I just see you comment,it was an error in windows, when i change the machine it works
worldpython
A: 

Hi, how did you stop it? I have the same problem.. Thanks

Anderson Severo
yes, just dire to server/tmp/ then search for your ejb temp file and remove it
worldpython
A: 
    public void stop(String timerName) {
    for(Object obj : timerService.getTimers()) {
        Timer t = (Timer)obj;
        if (t.getInfo().equals(timerName)) {
        t.cancel();
        }
    }
}
davideconsonni