4 Replies Latest reply on Jun 3, 2009 3:28 PM by israel.bgf

    EJB Timer with Seam: Is it really a bug?

    israel.bgf
      I want to post it in the JIRA (in fact, i dont know how yet), but i want to confirm if this is really a bug.

      As i have told in my other post, if a Seam component that triggers a timmer is used, an exception may be throw in the JBoss starting:

      13:55:53,646 ERROR [TimerImpl] Error invoking ejbTimeout: java.lang.RuntimeException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside an initialized application

      And it makes sense, the timer service tries to execute a method of a seam component before the seam application is started so it throws an error. To solve this i think that EJBs that are seam components should only be started after all the aplications in the server get started, or something like this.

      What you guys think?

      Israel
        • 1. Re: EJB Timer with Seam: Is it really a bug?
          kapitanpetko

          I don't think that this could be addressed in Seam. EJB timers know nothing about Seam,
          so there is no easy way to stop them from executing before Seam is initialized.
          You could check if Seam is initialized in your timer methods and do nothing if it is not,
          but that way you miss one execution, depending on your schedule, that may or may not be a problem.


          If you use Quartz you could pause the scheduler on startup or delay its initialization,
          but timing will be tricky. Since the timer service is part of J2EE, there is no way to
          control it from your application (at least none that I know of).


          HTH


          • 2. Re: EJB Timer with Seam: Is it really a bug?
            israel.bgf

            What you say is true, but theorically seam should be EJB friendly in every way, even for the not-so-used EJB Timers. :)


            I didnt test-it but, Jboss have JSF libs, so it get started as soon the server starts, could it works with seam-libs too?

            • 3. Re: EJB Timer with Seam: Is it really a bug?
              kapitanpetko

              Israel Fonseca wrote on Jun 02, 2009 15:48:


              What you say is true, but theorically seam should be EJB friendly in every way, even for the not-so-used EJB Timers. :)



              Sure. File a JIRA, see what happens. Maybe there are ways to handle this in Seam core.



              I didnt test-it but, Jboss have JSF libs, so it get started as soon the server starts, could it works with seam-libs too?


              Seam gets started by a context listener, so it will 'boot' after
              your application starts. The timer service, however, is started by the container and will start before your Seam
              app. There is no easy way around it. Unless you hooked into the timer service and start it from your Seam app (it's an
              MBean, I think, so should be doable). If you try it, be sure to post your code.

              • 4. Re: EJB Timer with Seam: Is it really a bug?
                israel.bgf

                Well, it's JIRAed:


                https://jira.jboss.org/jira/browse/JBSEAM-4216


                Unfortunately i dont have time now to check the fix as you sugested. But thks Nikolay.


                Israel