2 Replies Latest reply on Aug 31, 2008 11:39 AM by pmuir

    Quartz Container Transactions Messing Everything up...

    nynymike

      I'm using Seam 2.0.2.GA on Jboss 4.2.2


      This is a follow-up on this post:


        http://www.seamframework.org/Community/AsynchronousInvocationsAndTransactions


      John wrote:



      The cron should not be transactional, -or- the nested invocations within the cron must be nested and committed transactions, so that if an individual iteration fails, the overall cron is not rolled back, and if the overall cron fails, the individual iterations that have been completed remain committed

      This pretty much sums up my problem. My Quartz method looks like this:



          @Asynchronous
          @Transactional
          public QuartzTriggerHandle createQuartzAddTimer(@Expiration Date when, @IntervalCron String interval){
               String date = new Date().toString();
               try{
                    bulkAddPerson();
                } catch (Throwable e){
                     logrole.error(date + ": ERROR processing adds !!!");
                     StringWriter sw = new StringWriter();
                     PrintWriter pw = new PrintWriter(sw);
                     e.printStackTrace(pw);
                     String stackTrace = sw.toString();
                     logrole.error(stackTrace);
                }
               return null;
          }
        


      The method bulkAddPerson parses a flat file with usernames, and adds users by calling a method of an injected EJB session bean with the business logic.


      If one user fails, I want the script to continue. It does, but the transaction is messed up, and I start to see the error:


      Caused by: org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -76cb1f71:6910:48b3232a:381 s
      tatus: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac,
       BasicAction: -76cb1f71:6910:48b3232a:381 status: ActionStatus.ABORT_ONLY >)
      



      and then I start to see errors like this on all subsequent users:


      [ERROR] 25 Aug 18:00:36,843 - javax.ejb.NoSuchEJBException: Could not find stateful bean: 3t1g683z-si2qku-fkbll8dr-1-fkbmu9sp-3q
              at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:390)
              at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:375)
              at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:61)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      



      I've been looking at this for two days. I've tried to make the EJB3 TransactionAttribute REQUIRES NEW, but this doesn't work.


      Any ideas would be greatly appreciated. I sold everyone on the idea of using EJB to replace cron, and so far I'm paying a big price for that recommendation.


      Thanks in advance,


      Mike