Timer service won't work reliably...
tsar_bomba Jun 5, 2006 3:02 PMI've been working w/ some examples in the new Enterprise JavaBeans 3.0 book and I created a simple timer to run every 10 minutes and check for data integrity.
When JBoss decides to let it run, it works great. However it doesn't always work when I deploy the app....sometimes I get this exception:
11:45:20,480 ERROR [TimerServiceImpl] Cannot create txtimer java.lang.IllegalStateException: Unable to persist timer at org.jboss.ejb.txtimer.DatabasePersistencePolicy.insertTimer(DatabasePersistencePolicy.java:126) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155) at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264) at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659) at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) at $Proxy22.insertTimer(Unknown Source) at org.jboss.ejb.txtimer.TimerServiceImpl.createTimer(TimerServiceImpl.java:256) at org.jboss.ejb.txtimer.TimerServiceImpl.createTimer(TimerServiceImpl.java:202) at com.agribeef.abcommerce.service.PollingServiceBean.init(PollingServiceBean.java:32)
My timer looks like this:
@Stateless public class PollingServiceBean implements PollingService { @Resource private TimerService ts; private static final int timeout = 1000 * 60 * 10; //ten minutes public PollingServiceBean() { } public void init() { if (ts.getTimers().size() == 0) { this.ts.createTimer(5000, timeout, "pollServicesTimer"); } } @Timeout public void startService(Timer timer) { try { //do something here.... } catch (Exception exp) { // TODO Auto-generated catch block exp.printStackTrace(); } } }
First of all, what is "txtimer", I haven't named my timer that?
It runs sometimes and runs well...and then I re-deploy the same code and get the exception above...am I doing something wrong or is there a known problem?
Thanks!