7 Replies Latest reply on Jun 12, 2014 6:18 AM by Marek Novotny

    Asynchronous method in seam

    itays100 Newbie

      Hi All,


      I am running seam 2.1.2 with jpa (non ejb environment) and working with quartz 2.1.0 to schedule jobs in my application.

      In my components.xml i have:




      <async:quartz-dispatcher />


      While the job scheduler works perfectly, I have other requirements for calling Asynchronous methods and raiseEvent and not sure if I bound to

      use Quartz.


      This is my main concern: I am using Events.instance().raiseEvent("sendEmailEvent")

          This render an event:


                    public void sendSomeEmail() {



      When I try to use:

      Events.instance().raiseAsynchronousEvent("sendEmailEvent") I got an exception:


      SEVERE: Servlet.service() for servlet default threw exception

      java.lang.InstantiationError: org.quartz.JobDetail


        at org.jboss.seam.async.QuartzDispatcher.scheduleAsynchronousEvent(QuartzDispatcher.java:78)

        at org.jboss.seam.async.QuartzDispatcher.scheduleAsynchronousEvent(QuartzDispatcher.java:44)

        at org.jboss.seam.core.Events.raiseAsynchronousEvent(Events.java:99)



      It seems that AsynchronousEvent can't be used in my configuration. A workaround will be creating a Quartz job which raise the event. But realy

      this method raiseAsynchronousEvent is much easier. Is anyone got it working ?


      Thanks for you comments.

        • 1. Re: Asynchronous method in seam
          Marek Novotny Master

          seam doesn't support quartz 2. Just use what is integrated and included in seam 2 distribution.


          If you don't accept this I found a similar thread latest version of Quartz that will work with Seam 2.2 where somebody wrote he prepared upgrade for Quartz.

          • 2. Re: Asynchronous method in seam
            itays100 Newbie

            Thanks for the reply. I've upgraded to quartz 2 a while ago and can't remember what was the main reason.

            I'm using quartz 2 and created the following workaround:


            public class MyJob implements Job {


              public void execute(JobExecutionContext context) throws JobExecutionException {


                    SomeData someData = (SomeData) context.getJobDetail().getJobDataMap().get("someData");

                    Contexts.getEventContext().set("someData", someData);   






            I trigger the job from a seam action. In order to use the seam event I had to make a call to Lifecycle.

            There will be a call like this in every job triggering in the application. Can you see any problem with that ?



            • 3. Re: Asynchronous method in seam
              Marek Novotny Master

              That is what should work and org.jboss.seam.async.QuartzDispatcher.QuartzJob does so java.lang.InstantiationError: org.quartz.JobDetail should go away, but I haven't tried Quartz 2.x so practically I can't confirm it

              • 4. Re: Asynchronous method in seam
                itays100 Newbie

                well, I can confirm that it works. it just not as nice as using the seam asynchronous methods.

                • 5. Re: Asynchronous method in seam
                  Marek Novotny Master

                  well, it is a tax for not using integrated quartz and old seam 2. If you migrate to Seam 2.3.x you can use EJB timer services from Java EE 6 which are enhanced in comparison to Java EE 5  and you don't need Quartz then.

                  • 6. Re: Asynchronous method in seam
                    itays100 Newbie

                    I'm using 2.1.2 with jsf 1.2 and with jpa. So migration will be painful. I am down to two options now:

                    1. Use Quartz 2 with my seam 2.1.2 which include some not "very nice" code but works and get the benefits of performance improvement from Quartz 2.

                    2. I can downgrade to Quartz 1 (Existing jar from seam 2.1.2 lib) and I actually tried this today:


                    SomeData someData = (SomeData) context.getJobDetail().getJobDataMap().get("someData");

                      Contexts.getEventContext().set("someData", someData);  



                    After doing this I got the following exception:


                    ERROR [AsynchronousExceptionHandler] Exeception thrown whilst executing asynchronous call


                      at javax.mail.internet.InternetAddress.checkAddress(InternetAddress.java:1089)

                      at javax.mail.internet.InternetAddress.validate(InternetAddress.java:1071)

                      at org.jboss.seam.mail.ui.AddressComponent.getInternetAddress(AddressComponent.java:39)

                      at org.jboss.seam.mail.ui.RecipientAddressComponent.encodeBegin(RecipientAddressComponent.java:25)

                      at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:172)

                      at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163)

                      at org.jboss.seam.mail.ui.UIMessage.encodeChildren(UIMessage.java:192)

                      at org.jboss.seam.ui.util.JSF.renderChild(JSF.java:175)

                      at org.jboss.seam.ui.util.JSF.renderChildren(JSF.java:163)


                    From the exception it looks like the Asynchronous event can't find the object I set in the context. Do you know what is required for

                    the Asynchronous event to know about "someData" obkect ?


                    • 7. Re: Asynchronous method in seam
                      Marek Novotny Master

                      hmm, your point is valid even 2.1.2 is too old and you should use at least 2.2.2.Final to grab all fixes.


                      With regarding asynchronous event there is no additional thing. There has to be something else causing the error.