2 Replies Latest reply on Jan 18, 2007 11:30 AM by smeaggie

    seam, pojo and a user thread...?

    smeaggie

      Hi all, I'm pretty new to seam, but I managed to get it working with everything I need, except for this one! I need a very simple task executed every 10 seconds, switching on and off from the web interface, starting immediatly at deploy time and automaticly stop at undeploy or jboss shutdown. Don't worry, most parts work ;)

      I use a simple java.util.Timer to accomplish this and some annotations to expose to seam. This is (somewhat simplified) my code:

      @Name("MyService")
      @Scope(ScopeType.APPLICATION)
      @Startup()
      public class MyService {
       private Timer timer;
      
       @Create()
       public void start() {
       this.timer = new Timer();
       this.timer.scheduleAtFixedRate(new MyTask(), 0, 10000);
       }
      
       @Destroy()
       public void stop() {
       this.timer.cancel();
       }
      }
      


      Code works perfectly, it's started on deploy time automaticly, and the methods are callable by the web interface wich stops and starts the timer as expected. However, on undeploy or shutting down jboss, I get the following exception:
      [Contexts] Could not destroy component: MyService
      java.lang.IllegalStateException: No active event context
      <--- impressive stack trace goes here --->
      

      and the timer keeps running...

      Can someone help me out here? Thanks in advance,
      Eric