7 Replies Latest reply on Jul 5, 2007 3:03 PM by Gavin King

    Can not persist EJB3 Timer since  Jboss 4.2.0cr2 + seam from

    Gena Newbie

      Hi, while i'm trying to persist one start and one end timer, i get following exception. Some details on the unit of work: I persist my object (object graph) at the end of long running conversation with extended persistent context. Then i do em.flash() and (if all succeeded) i wish to schedule two timers (for one execution in a future). Then i get this exception:

      03:07:07,448 ERROR [STDERR] org.jboss.resource.connectionmanager.JBossLocalXAException: Trying to start a new tx when old is not complete! old: < 131075, 29, 27, 1--3f57feec:1029:462bf231:671-3f57feec:1029:462bf231:6f1
      03:07:07,464 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource.start(TxConnectionManager.java:886)
      03:07:07,464 ERROR [STDERR] at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:701)
      03:07:07,464 ERROR [STDERR] at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:446)
      03:07:07,464 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener$TransactionSynchronization.enlist(TxConnectionManager.java:773)
      03:07:07,464 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:564)
      03:07:07,464 ERROR [STDERR] at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:337)
      03:07:07,464 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2.reconnectManagedConnection(BaseConnectionManager2.java:518)
      03:07:07,464 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:399)
      03:07:07,464 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)
      03:07:07,464 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)
      03:07:07,464 ERROR [STDERR] at org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin.insertTimer(GeneralPurposeDatabasePersistencePlugin.java:199)
      03:07:07,464 ERROR [STDERR] at org.jboss.ejb.txtimer.DatabasePersistencePolicy.insertTimer(DatabasePersistencePolicy.java:120)
      03:07:07,464 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      03:07:07,464 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      03:07:07,464 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      03:07:07,464 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
      03:07:07,479 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      03:07:07,479 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      03:07:07,479 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      03:07:07,479 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      03:07:07,479 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      03:07:07,479 ERROR [STDERR] at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      03:07:07,479 ERROR [STDERR] at $Proxy30.insertTimer(Unknown Source)
      03:07:07,479 ERROR [STDERR] at org.jboss.ejb.txtimer.TimerServiceImpl.createTimer(TimerServiceImpl.java:256)
      03:07:07,479 ERROR [STDERR] at org.jboss.ejb.txtimer.TimerServiceImpl.createTimer(TimerServiceImpl.java:222)
      03:07:07,479 ERROR [STDERR] at org.jboss.ejb3.timerservice.jboss.TimerServiceFacade.createTimer(TimerServiceFacade.java:61)
      03:07:07,479 ERROR [STDERR] at org.jboss.seam.core.Dispatcher.schedule(Dispatcher.java:224)
      03:07:07,479 ERROR [STDERR] at org.jboss.seam.core.Dispatcher.scheduleInvocation(Dispatcher.java:205)
      03:07:07,479 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      03:07:07,479 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      03:07:07,479 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      03:07:07,479 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)
      03:07:07,479 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
      

      The problem is, it did work on jboss 4.0.5 with seam 1.2.0. Could someone please explain, if there are some changes in the implementation or where is my error.

      Many thanks,

      Gena

        • 1. Re: Can not persist EJB3 Timer since  Jboss 4.2.0cr2 + seam
          Pete Muir Master

          Are you using EJB3 timers? If so, then the EJB3 implantation version will have been changed from 4.0.5 to 4.2.0.CR2.

          • 2. Re: Can not persist EJB3 Timer since  Jboss 4.2.0cr2 + seam
            Gena Newbie

            Hello, i'm using the seam-wrapper for EJB3 timers via @Asynchronous. In a simple case it works fine:

            Timer iface:

            @Local
            public interface TimerTester {
             @Asynchronous
             public abstract Timer say(String what, @Expiration
             Date expireTime, @IntervalDuration
             Long intervallDuration, @Duration Long duration);
            }


            Timer Bean:
            @Name("timerTester")
            @AutoCreate
            @Stateless
            public class TimerTesterImpl implements TimerTester{
             @In
             Timer timer;
             @Resource
             TimerService timerService;
             public Timer say(String what, Date expireTime, Long intervallDuration, Long duration) {
             System.out.println(what);
             return timer;
             }
            }


            controller (stateless bean with local iface):

            public void sayHello() {
             Timer timer =timerTester.say("hello", new Date(System.currentTimeMillis()+1000), 10000l,10l);
             log.info(timer, null);
             }


            Page
            <h:commandLink value="Say Hello!" action="#{sampleController.sayHello}"/>



            My case, which doesn't work anymore:

            SFSB:
            ...
            @In(create = true)
             OfferLifecycle offerLifecycle;
            ...
            if (persistOffer()) {
             if (schedule) {
            
             timer = offerLifecycle.scheduleOfferStart(inOffer.getId(), inOffer.getStartTimestamp());
            
             debug("offer start pending with timer ");
            
             timer = offerLifecycle.scheduleOfferEnd(inOffer.getId(), inOffer.getEndTimestamp());
            
             debug("offer end pending with timer");
             }

            Timer bean:

            @Local
            public interface OfferLifecycle {
             @Asynchronous
             public abstract Timer scheduleOfferStart(Long offerId, @Expiration
             Date startTime);
             @Asynchronous
             public abstract Timer scheduleOfferEnd(Long offerId, @Expiration
             Date expireTime);
            }


            @Stateless
            @Name("offerLifecycle")
            public class OfferLifecycleBean implements OfferLifecycle {
            
             @In(create = true)
             OfferDAO offerDAO;
             @In
             Timer timer;
             @Resource
             TimerService timerService;
            
             public Timer scheduleOfferStart(Long offerId, Date startTime) {
             offerStart(loadOffer(offerId));
             return timer;
             }
             public Timer scheduleOfferEnd(Long offerId, Date expireTime) {
            
             offerEnd(loadOffer(offerId));
             return timer;
             }
            private Offer loadOffer(Long offerId) {
             return offerDAO.findById( offerId,
             LockMode.UPGRADE);
             }


            persistOffer() has flushed the session (because of flush mode manual)

            • 3. Re: Can not persist EJB3 Timer since  Jboss 4.2.0cr2 + seam
              Gena Newbie

              Ok, i've found it!

              Since the new jboss ts implementation supports only one local-tx-resource per distributed transaction, the timer can not be commited until a bean uses more then one local-tx resource. Timers are hosted by default within the non xa hsqldb. So if we use in our transaction also one another local-tx data source, the exception above occurs!

              I've switched from local-tx to xa data source and the timers work fine!

              • 4. Re: Can not persist EJB3 Timer since  Jboss 4.2.0cr2 + seam
                Gena Newbie

                Ok, i've found it!

                Since the new jboss ts implementation supports only one local-tx-resource per distributed transaction, the timer can not be commited until a bean uses more then one local-tx resource. Timers are hosted by default within the non xa hsqldb. So if we use in our transaction also one another local-tx data source, the exception above occurs!

                I've switched from local-tx to xa data source and the timers work fine!

                • 5. Re: Can not persist EJB3 Timer since  Jboss 4.2.0cr2 + seam
                  Kevin Pauli Newbie

                  I'm seeing the same problem here, with the 4.2.0GA release (though we are not using the Seam annotation to create it, we're invoking the TimerService directly).

                  It seems a shame to have to go XA just to get timer functionality. I mean, everything is on the same box, in the same database. Shouldn't it work with a local-tx-datasource as long as the same ds is used throughout?

                  • 6. Re: Can not persist EJB3 Timer since  Jboss 4.2.0cr2 + seam
                    Gena Newbie

                    i think, it could, but we use now two different ds one for JBoss and one for our application. In the future, we plan to switch the jboss ds to our production one. Do you think, the XA were the performance killer or a source of system instability?

                    • 7. Re: Can not persist EJB3 Timer since  Jboss 4.2.0cr2 + seam
                      Gavin King Master

                       

                      "kevinpauli" wrote:
                      I'm seeing the same problem here, with the 4.2.0GA release (though we are not using the Seam annotation to create it, we're invoking the TimerService directly).

                      It seems a shame to have to go XA just to get timer functionality. I mean, everything is on the same box, in the same database. Shouldn't it work with a local-tx-datasource as long as the same ds is used throughout?


                      Should work fine if the timer service and the app both use the same local-tx datasource.