4 Replies Latest reply on Oct 3, 2007 7:23 PM by pmuir

    Problem with TimerService

    hasc

      Hello,

      i wrote a simple stateless bean to test the TimerService. i am using jboss 4.2.0GA

      Whenerver i initialize the time i run into the following exception:


      2007-10-02 14:56:55,437 ERROR [org.jboss.ejb.txtimer.TimerServiceImpl] Cannot create txtimer
      java.lang.IllegalStateException: Unable to persist timer
       at org.jboss.ejb.txtimer.DatabasePersistencePolicy.insertTimer(DatabasePersistencePolicy.java:124)
       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.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
       at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:437)
       at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:381)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: org.jboss.util.NestedSQLException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: -3f57fdff:555:47023fba:53 status: ActionStatus.ABORT_ONLY >); - nested throwable: (org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: -3f57fdff:555:47023fba:53 status: ActionStatus.ABORT_ONLY >))
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:94)
       at org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin.insertTimer(GeneralPurposeDatabasePersistencePlugin.java:199)
       at org.jboss.ejb.txtimer.DatabasePersistencePolicy.insertTimer(DatabasePersistencePolicy.java:120)
       ... 317 more
      Caused by: org.jboss.resource.JBossResourceException: Could not enlist in transaction on entering meta-aware object!; - nested throwable: (javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: -3f57fdff:555:47023fba:53 status: ActionStatus.ABORT_ONLY >)
       at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:343)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnectManagedConnection(BaseConnectionManager2.java:518)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:399)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
       ... 319 more
      Caused by: javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple < ac, BasicAction: -3f57fdff:555:47023fba:53 status: ActionStatus.ABORT_ONLY >
       at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchronization.checkEnlisted(TxConnectionManager.java:744)
       at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:577)
       at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:337)
       ... 323 mor


      I googled a bit and found some issues. Now I still dont know what to do. Do i need to configure the TimerService with my database (MySQL)? I think for me its not neccessary to persist the status. Its enough for me if the timer is executed as long as the application is running.

      Any hints would be great.

      regards,
      hasc

        • 1. Re: Problem with TimerService
          hasc

          would also be great if someone can point me to a useful reference or thread.

          regards,
          hasc

          • 2. Re: Problem with TimerService
            pmuir

            Post code showing what you are trying to do

            • 3. Re: Problem with TimerService
              hasc

              bean using the TimerService:


              @Stateless
              @Name("listener")
              public class DBChangeListenerService implements DBChangeListener {
              
               @Resource TimerService timerservice;
              
               @Logger Log log;
              
               public DBChangeListenerService() {}
              
               public void initTimer() {
               log.info("initTimer");
               timerservice.createTimer(2*60*1000, 2*60*1000,"DBChangeListener");
               }
              
               @Timeout
               public void queryState(Timer timer) {
               log.info("query db state");
               }
              }


              and the bean calling the initTimer() method

              @Stateless
              @AutoCreate
              @Name("objectcache")
              public class ObjectCacheService implements ObjectCache{
              
              
               @In(create=true)
               DBChangeListenerService listener;
              
               public void init() {
               listener.initTimer();
               }
              }
              


              Thanks for your help

              • 4. Re: Problem with TimerService
                pmuir

                Ask on the EJB3 forum, nothing to do with Seam (or use Seam's support for asynchronous methods).