javajakarta-eetimerresin

java ejb TimerService: cancelled timer returned by getTimers (resin caucho)


I'm trying to cancel timer but after that I still have it returning by getTimers(). Is it ok or just a caucho resin bug? How to cancel programmatic timer correctly?

@Singleton
@LocalBean
@Startup
public class TimerTest
{
    @Resource
    TimerService ts;
    static TimerTest inst;

    @PostConstruct
    void init()
    {   inst=this;
    }

    public synchronized static TimerTest getInstance()
    {   return(inst);
    }

    public Collection<Timer> getTimers()
    {   Collection <Timer> res=ts.getTimers();
        return(res);
    }

    public void cancelAll()
    {   for(Timer ot: ts.getTimers())
        {   try
            {   System.out.println("Found old timer "+ot.getInfo()+", cancelling it.");
                ot.cancel();
            }
            catch(Exception e) {}
        }
    }

And then (from jsp):

TimerTest tt=TimerTest.getInstance();
Collection <Timer> timers=tt.getTimers();
out.println("<br>Got "+timers.size()+" timer(s)<br>");
for(Timer t: timers)
{
    try
    {
        out.println("<br>Got timer: "+t.getInfo());
    }
    catch(Exception e)
    {
        out.println("Error while cancelling timers "+e);
    }
}

Error while cancelling timers javax.ejb.NoSuchObjectLocalException: This timer has been cancelled.

Thank you! )


Solution

  • Got answer here: http://bugs.caucho.com/view.php?id=5891

    06-03-15 08:50 ferg Assigned To => ferg

    06-03-15 08:50 ferg Status new => closed

    06-03-15 08:50 ferg Resolution open => fixed

    06-03-15 08:50 ferg Fixed in Version => 4.0.45