4 Replies Latest reply on Jun 8, 2007 1:35 PM by maniappan

    Timer not starting from method with @Create annotation.

    maniappan

      I try to start a timer with one minute interval using @Asynchronous annotation. when I schedule this timer from within any method in my application it seems to work properly. However when I try to invoke it from a @Create annotated method during startup the timer is not getting set, I see this error in the log.

      2007-06-08 14:36:26,756 ERROR [org.jboss.ejb.txtimer.TimerImpl] Error invoking ejbTimeout: javax.ejb.EJBException: java.lang.NullPointerException:
      2007-06-08 14:36:26,756 DEBUG [org.jboss.ejb.txtimer.TimerImpl] Timer was not registered with Tx, resetting state: [id=4,target=[target=jboss.j2ee:service=EJB3,ear=myapp.ear,jar=jboss-seam.jar,name=Dispatcher],remaining=-1048568,periode=60000,in_timeout]
      


      Here is the code snippet where I invoke the timer..
      @Startup
      @Entity
      @Local
      @Table(name="myapp_schedule")
      @Stateful
      @Scope(ScopeType.APPLICATION)
      @Name("myappSchedule")
      public class MyappSchedule
       implements Serializable, MyappScheduleInterface
      {
      -- Setters/Getters for all fields in the table..
       @Create
       public void startScheduler() {
       log.info("Entering create now to start the schdeuler");
       try{Thread t = new Thread();
       t.sleep(10000);}
       catch(Exception e){}
       try {
       MyappScheduleController ysh = (MyappScheduleController) Component.getInstance("myappScheduleHome");
       ysh.saveAndSchedule();
       } catch (Exception e) {
       System.out.println("Got the exception while starting time "+e.toString());
       }
       }
      
       @Destroy @Remove
       public void dummy() {}
      }
      


      When I invoke the saveAndSchedule() from any other method from application it works properly, not in the case above..
      Any ideas on where could be the issue?


        • 1. Re: Timer not starting from method with @Create annotation.
          pmuir

          You need to find out why the NPE is thrown - for some reason the as isn't giving you the whole stack trace, wrap the method in a try catch and print the stack trace

          • 2. Re: Timer not starting from method with @Create annotation.
            maniappan

            Hi Pete
            I have the exceptions caught for the scheduler, processor methods as well as the place where I invoke the saveAndSchedule() method. Don't see any other exception raised. The exception seems to happen after certain time period(I see all the relevant operations completed on the schedule object by that time like closing the JDBC connection, invalidating the objects etc.) after which the exception pasted by me is thrown at the end.

            I am not sure if I saw the right source here, org/jboss/ejb/txtimer/TimerImpl.java code seem to throw this exception on some timeout, not sure what could cause this timeout in my case.
            -- Mani.

            • 3. Re: Timer not starting from method with @Create annotation.
              pmuir

               

              2007-06-08 14:36:26,756 ERROR [org.jboss.ejb.txtimer.TimerImpl] Error invoking ejbTimeout: javax.ejb
              .EJBException: java.lang.NullPointerException:


              @Create
               public void startScheduler() {
               try {
               log.info("Entering create now to start the schdeuler");
               try{Thread t = new Thread();
               t.sleep(10000);}
               catch(Exception e){}
               try {
               MyappScheduleController ysh = (MyappScheduleController) Component.getInstance("myappScheduleHome");
               ysh.saveAndSchedule();
               } catch (Exception e) {
               System.out.println("Got the exception while starting time "+e.toString());
               }
               } catch (Exception e) {
               e.printStackTrace();
               }
               }


              • 4. Re: Timer not starting from method with @Create annotation.
                maniappan

                Tried it, didn't get any exception, got more line in addition to what I posted before..

                2007-06-08 22:42:49,066 DEBUG [org.jboss.ejb.txtimer.TimerImpl] Timer was not registered with Tx, resetting state: [id=4,target=[target=jboss.j2ee:service=EJB3,ear=yoscarebase.ear,jar=jboss-seam.jar,name=Dispatcher],remaining=-11966,periode=0,in_timeout]
                2007-06-08 22:42:49,066 DEBUG [org.jboss.ejb.txtimer.TimerImpl] setTimerState: expired
                2007-06-08 22:42:49,067 DEBUG [org.jboss.ejb.txtimer.TimerImpl] killTimer: [id=4,target=[target=jboss.j2ee:service=EJB3,ear=yoscarebase.ear,jar=jboss-seam.jar,name=Dispatcher],remaining=-11967,periode=0,expired]
                2007-06-08 22:42:49,068 DEBUG [org.jboss.ejb.txtimer.GeneralPurposeDatabasePersistencePlugin] Unable to remove timer for: 4