-
1. Re: Asynchronous method in seam
manarh Jun 5, 2014 2:53 PM (in response to itays100)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 Jun 6, 2014 5:09 AM (in response to manarh)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 {
@Transactional
public void execute(JobExecutionContext context) throws JobExecutionException {
Lifecycle.beginCall();
SomeData someData = (SomeData) context.getJobDetail().getJobDataMap().get("someData");
Contexts.getEventContext().set("someData", someData);
Events.instance().raiseEvent("someEvent");
Lifecycle.endCall();
}
}
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 ?
Thanks.
-
3. Re: Asynchronous method in seam
manarh Jun 6, 2014 6:33 AM (in response to itays100)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 Jun 6, 2014 8:04 AM (in response to manarh)well, I can confirm that it works. it just not as nice as using the seam asynchronous methods.
-
5. Re: Asynchronous method in seam
manarh Jun 6, 2014 8:31 AM (in response to itays100)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 Jun 10, 2014 12:51 PM (in response to manarh)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);
Events.instance().raiseAsynchronousEvent("someEvent");
After doing this I got the following exception:
ERROR [AsynchronousExceptionHandler] Exeception thrown whilst executing asynchronous call
java.lang.NullPointerException
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 ?
Thanks.
-
7. Re: Asynchronous method in seam
manarh Jun 12, 2014 6:18 AM (in response to itays100)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.