9 Replies Latest reply: Aug 31, 2007 3:55 PM by Sheldon s RSS

Timers from previous deployments are still persistent

Sheldon s Newbie

I have a ScheduleController that schedule tasks:

@Startup
@Scope(ScopeType.APPLICATION)
@Name("scheduleController")
public class ScheduleController {
 @In
 private Schedule schedule;

 @In(create=true)
 private ScheduledTask aTask;

 @Create
 public void scheduleAllTasks() {
 // this is for test only
 List<ScheduledTask> perMinuteTasks = new ArrayList<ScheduledTask>();
 perMinuteTasks.add(aTask);
 // starts 3 minutes later, once every two minutes
 schedule.runIntervaledTask(180000L, 120000L, perMinuteTasks);
 }
}

Schedule.java has the asynchronous method:
 @Asynchronous
 public Timer runIntervaledTask(@Duration Long delay,
 @IntervalDuration long interval,
 List<ScheduledTask> tasks) {
 if (tasks != null) {
 for (ScheduledTask task : tasks) {
 task.execute();
 }
 }
 return null;
 }


After a few redeployment, it seems that I have timers from previous deployments still executing. In the console I saw these messages:


11:08:42,593 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,609 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,625 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,625 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,625 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,625 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,640 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,640 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,656 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,656 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,671 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,687 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,703 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,703 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,703 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,703 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,718 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,734 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,734 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,734 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,750 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,750 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,765 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,765 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,781 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,781 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,796 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,796 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,812 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,812 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,843 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,859 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,859 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,859 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,875 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,890 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,890 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,890 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,906 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,921 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,953 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,953 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,953 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,953 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,984 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:42,984 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:43,000 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:43,000 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:43,015 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:43,031 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:43,046 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:43,046 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:43,062 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application
11:08:43,078 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the context of a web application


  • 1. Re: Timers from previous deployments are still persistent
    Gavin King Master

    Right, EJB timers are persistent.

    In Seam 1.3 we give you a choice b/w (persistent) EJB timers and (non-persistent) java.util.concurrent timers.

  • 2. Re: Timers from previous deployments are still persistent
    Sheldon s Newbie

    ok. any idea when Seam 1.3 will GA?

  • 3. Re: Timers from previous deployments are still persistent
    Marcelo Farinelli Newbie

    tuxzilla, I'm doing exactly the same thing, and having the same problem.

    Take a look at your \JBOSS_HOME\server\default\data\hypersonic dir. You will find a file named localDB.log

    Open this file. You will see something like this:

    After the first deploy:
    INSERT INTO TIMERS VALUES('1','[target=jboss.j2ee:service=EJB3,ear=consultoria.ear,jar=jboss-seam.jar,name=Dispatcher]','2007-06-14 18:18:35.732000000',30000,NULL,'aced0005737200356f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573496e766f636174696f6e670f265d0e3c68ee0200045b000861726754797065737400125b4c6a6176612f6c616e672f436c6173733b5b0004617267737400135b4c6a6176612f6c616e672f4f626a6563743b4c000d636f6d706f6e656e744e616d657400124c6a6176612f6c616e672f537472696e673b4c000a6d6574686f644e616d6571007e00037872002b6f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573f8597006e73beecb0200024c000970726f6365737349647400104c6a6176612f6c616e672f4c6f6e673b4c00067461736b496471007e000578707070757200125b4c6a6176612e6c616e672e436c6173733bab16d7aecbcd5a99020000787000000002767200046c6f6e670000000000000000000000787071007e000a757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c0200007870000000027372000e6a6176612e6c616e672e4c6f6e673b8be490cc8f23df0200014a000576616c7565787200106a6176612e6c616e672e4e756d62657286ac951d0b94e08b0200007870000000000000ea607371007e000d000000000000753074000e7370686368614f627365727665727400076f627365727665')
    COMMIT
    SET AUTOCOMMIT TRUE
    
    When you redeploy:
    DELETE FROM TIMERS WHERE TIMERID='1' AND TARGETID='[target=jboss.j2ee:service=EJB3,ear=consultoria.ear,jar=jboss-seam.jar,name=Dispatcher]'
    INSERT INTO TIMERS VALUES('2','[target=jboss.j2ee:service=EJB3,ear=consultoria.ear,jar=jboss-seam.jar,name=Dispatcher]','2007-06-14 18:18:35.732000000',30000,NULL,'aced0005737200356f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573496e766f636174696f6e670f265d0e3c68ee0200045b000861726754797065737400125b4c6a6176612f6c616e672f436c6173733b5b0004617267737400135b4c6a6176612f6c616e672f4f626a6563743b4c000d636f6d706f6e656e744e616d657400124c6a6176612f6c616e672f537472696e673b4c000a6d6574686f644e616d6571007e00037872002b6f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573f8597006e73beecb0200024c000970726f6365737349647400104c6a6176612f6c616e672f4c6f6e673b4c00067461736b496471007e000578707070757200125b4c6a6176612e6c616e672e436c6173733bab16d7aecbcd5a99020000787000000002767200046c6f6e670000000000000000000000787071007e000a757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c0200007870000000027372000e6a6176612e6c616e672e4c6f6e673b8be490cc8f23df0200014a000576616c7565787200106a6176612e6c616e672e4e756d62657286ac951d0b94e08b0200007870000000000000ea607371007e000d000000000000753074000e7370686368614f627365727665727400076f627365727665')
    SET AUTOCOMMIT FALSE
    INSERT INTO TIMERS VALUES('3','[target=jboss.j2ee:service=EJB3,ear=consultoria.ear,jar=jboss-seam.jar,name=Dispatcher]','2007-06-14 18:20:18.230000000',30000,NULL,'aced0005737200356f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573496e766f636174696f6e670f265d0e3c68ee0200045b000861726754797065737400125b4c6a6176612f6c616e672f436c6173733b5b0004617267737400135b4c6a6176612f6c616e672f4f626a6563743b4c000d636f6d706f6e656e744e616d657400124c6a6176612f6c616e672f537472696e673b4c000a6d6574686f644e616d6571007e00037872002b6f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573f8597006e73beecb0200024c000970726f6365737349647400104c6a6176612f6c616e672f4c6f6e673b4c00067461736b496471007e000578707070757200125b4c6a6176612e6c616e672e436c6173733bab16d7aecbcd5a99020000787000000002767200046c6f6e670000000000000000000000787071007e000a757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c0200007870000000027372000e6a6176612e6c616e672e4c6f6e673b8be490cc8f23df0200014a000576616c7565787200106a6176612e6c616e672e4e756d62657286ac951d0b94e08b0200007870000000000000ea607371007e000d000000000000753074000e7370686368614f627365727665727400076f627365727665')
    COMMIT
    SET AUTOCOMMIT TRUE
    
    When you redeploy again:
    DELETE FROM TIMERS WHERE TIMERID='2' AND TARGETID='[target=jboss.j2ee:service=EJB3,ear=consultoria.ear,jar=jboss-seam.jar,name=Dispatcher]'
    DELETE FROM TIMERS WHERE TIMERID='3' AND TARGETID='[target=jboss.j2ee:service=EJB3,ear=consultoria.ear,jar=jboss-seam.jar,name=Dispatcher]'
    INSERT INTO TIMERS VALUES('4','[target=jboss.j2ee:service=EJB3,ear=consultoria.ear,jar=jboss-seam.jar,name=Dispatcher]','2007-06-14 18:18:35.732000000',30000,NULL,'aced0005737200356f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573496e766f636174696f6e670f265d0e3c68ee0200045b000861726754797065737400125b4c6a6176612f6c616e672f436c6173733b5b0004617267737400135b4c6a6176612f6c616e672f4f626a6563743b4c000d636f6d706f6e656e744e616d657400124c6a6176612f6c616e672f537472696e673b4c000a6d6574686f644e616d6571007e00037872002b6f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573f8597006e73beecb0200024c000970726f6365737349647400104c6a6176612f6c616e672f4c6f6e673b4c00067461736b496471007e000578707070757200125b4c6a6176612e6c616e672e436c6173733bab16d7aecbcd5a99020000787000000002767200046c6f6e670000000000000000000000787071007e000a757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c0200007870000000027372000e6a6176612e6c616e672e4c6f6e673b8be490cc8f23df0200014a000576616c7565787200106a6176612e6c616e672e4e756d62657286ac951d0b94e08b0200007870000000000000ea607371007e000d000000000000753074000e7370686368614f627365727665727400076f627365727665')
    INSERT INTO TIMERS VALUES('5','[target=jboss.j2ee:service=EJB3,ear=consultoria.ear,jar=jboss-seam.jar,name=Dispatcher]','2007-06-14 18:20:18.230000000',30000,NULL,'aced0005737200356f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573496e766f636174696f6e670f265d0e3c68ee0200045b000861726754797065737400125b4c6a6176612f6c616e672f436c6173733b5b0004617267737400135b4c6a6176612f6c616e672f4f626a6563743b4c000d636f6d706f6e656e744e616d657400124c6a6176612f6c616e672f537472696e673b4c000a6d6574686f644e616d6571007e00037872002b6f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573f8597006e73beecb0200024c000970726f6365737349647400104c6a6176612f6c616e672f4c6f6e673b4c00067461736b496471007e000578707070757200125b4c6a6176612e6c616e672e436c6173733bab16d7aecbcd5a99020000787000000002767200046c6f6e670000000000000000000000787071007e000a757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c0200007870000000027372000e6a6176612e6c616e672e4c6f6e673b8be490cc8f23df0200014a000576616c7565787200106a6176612e6c616e672e4e756d62657286ac951d0b94e08b0200007870000000000000ea607371007e000d000000000000753074000e7370686368614f627365727665727400076f627365727665')
    SET AUTOCOMMIT FALSE
    INSERT INTO TIMERS VALUES('6','[target=jboss.j2ee:service=EJB3,ear=consultoria.ear,jar=jboss-seam.jar,name=Dispatcher]','2007-06-14 18:39:02.897000000',30000,NULL,'aced0005737200356f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573496e766f636174696f6e670f265d0e3c68ee0200045b000861726754797065737400125b4c6a6176612f6c616e672f436c6173733b5b0004617267737400135b4c6a6176612f6c616e672f4f626a6563743b4c000d636f6d706f6e656e744e616d657400124c6a6176612f6c616e672f537472696e673b4c000a6d6574686f644e616d6571007e00037872002b6f72672e6a626f73732e7365616d2e636f72652e44697370617463686572244173796e6368726f6e6f7573f8597006e73beecb0200024c000970726f6365737349647400104c6a6176612f6c616e672f4c6f6e673b4c00067461736b496471007e000578707070757200125b4c6a6176612e6c616e672e436c6173733bab16d7aecbcd5a99020000787000000002767200046c6f6e670000000000000000000000787071007e000a757200135b4c6a6176612e6c616e672e4f626a6563743b90ce589f1073296c0200007870000000027372000e6a6176612e6c616e672e4c6f6e673b8be490cc8f23df0200014a000576616c7565787200106a6176612e6c616e672e4e756d62657286ac951d0b94e08b0200007870000000000000ea607371007e000d000000000000753074000e7370686368614f627365727665727400076f627365727665')
    COMMIT
    
    And so on...
    


    As you can see, after your first redeploy, it deletes the timer, and them inserts it again 2 times. When you redeploy again, it deletes the same 2 timers and inserts it 3 times... and so on...

    That's odd, as it seems it is doing things right deleting the timer and inserting it again when you redeploy, but it is inserting the timer aways one time more than necessary.

    I tried removing the timers from EJBContext but all I got was a NPE. I searched all over the place and did not find any other way to remove the timer... will upgrade to 1.3 if that solves the problem.

  • 4. Re: Timers from previous deployments are still persistent
    Sheldon s Newbie

    Yes, I will wait for 1.3.0

  • 5. Re: Timers from previous deployments are still persistent
    Monkey Den Master

    Same issue. I couldn't figure out why my async method was being called so many times. Any idea of how truncate that table on startup?

  • 6. Re: Timers from previous deployments are still persistent
    Michael Yuan Novice

    I am not sure about EJB3 timer. But I just want to add that the Quartz timer can now be persistent or in-memory. Just configure a DB in the seam.quartz.properties file if you need it to be persistence.

  • 7. Re: Timers from previous deployments are still persistent
    Monkey Den Master

    Thanks Michael. I don't really want it to be persistent, because my application-scoped Seam component is going to unknowingly create another the next time I restart/redeploy. Is there some way to uniquely identity the timer, so on start up if finds the record?

  • 8. Re: Timers from previous deployments are still persistent
    Monkey Den Master

    to elaborate, I want exactly one of these running for the application.

  • 9. Re: Timers from previous deployments are still persistent
    Sheldon s Newbie

    One solution that helps is to have a @Destroy method in which you cancel the timer using timer.cancel().