1 Reply Latest reply on Jul 14, 2009 5:54 AM by jaikiran pai

    TimerService.createTimer()  in @Service POJO, 4.2.3 vs 5.1.0

    Ville Skyttä Newbie

      Hello,

      When migrating @Service POJOs from JBoss AS 4.2.3 to 5.1.0, I ran into a problem (bug?) with EJB timers (among others, more about those later in separate posts) . Simplified example:

      DummyService.java:

      package example;
      
      public interface DummyService
      {
       void start()
       throws Exception;
      }


      DummyServiceBean.java:

      package example;
      
      import java.util.Date;
      
      import javax.annotation.Resource;
      import javax.ejb.Timeout;
      import javax.ejb.Timer;
      import javax.ejb.TimerService;
      
      import org.jboss.ejb3.annotation.Management;
      import org.jboss.ejb3.annotation.Service;
      
      @Service
      @Management(DummyService.class)
      public class DummyServiceBean
       implements DummyService
      {
       @Resource
       protected TimerService timerService;
      
       public void start()
       throws Exception
       {
       timerService.createTimer(new Date(), 5000, "DUMMY");
       }
      
       @Timeout
       public void timeout(Timer timer)
       {
       System.out.println("PING");
       }
      }


      This works with AS 4.2.3 (annotation packages obviously changed to the old ones), but the createTimer() fails in 5.1.0 with an InvocationTargetException whose root cause is:

      Caused by: java.lang.IllegalStateException: Cannot obtain inMethodFlag for: TimerService.createTimer
       at org.jboss.ejb.AllowedOperationsAssociation.assertAllowedIn(AllowedOperationsAssociation.java:145)
       at org.jboss.as.ejb3.timerservice.TimerServiceFacade.assertAllowedIn(TimerServiceFacade.java:59)
       at org.jboss.as.ejb3.timerservice.TimerServiceFacade.createTimer(TimerServiceFacade.java:64)
       at example.DummyServiceBean.start(DummyServiceBean.java:24)
      [...]


      I don't remember seeing any instructions except the annotation package changes in the 5.x release notes for migrating @Service POJOs. Ideas?