Quartz integration with vaadin CDI

Hi,

I have application that is running on top of the Vaadin CDI addon. I have tried to integrate the quartz framework following this tutorial (http://www.javacodegeeks.com/2014/05/how-to-quartz-scheduler-with-clustering-in-jee-application-with-mysql.html), but once I run my application I got this exception

Caused by: java.lang.NullPointerException
at com.vaadin.cdi.internal.CDIUtil.getSessionId(CDIUtil.java:64) [vaadin-cdi-1.0.2.jar:1.0.2]

at com.vaadin.cdi.internal.CDIUtil.getSessionId(CDIUtil.java:59) [vaadin-cdi-1.0.2.jar:1.0.2]

at com.vaadin.cdi.internal.ViewBean.<init>(ViewBean.java:42) [vaadin-cdi-1.0.2.jar:1.0.2]

at com.vaadin.cdi.internal.ViewScopedContext.wrapBean(ViewScopedContext.java:57) [vaadin-cdi-1.0.2.jar:1.0.2]

at com.vaadin.cdi.internal.AbstractVaadinContext.get(AbstractVaadinContext.java:156) [vaadin-cdi-1.0.2.jar:1.0.2]

at com.vaadin.cdi.internal.ContextWrapper.get(ContextWrapper.java:49) [vaadin-cdi-1.0.2.jar:1.0.2]

at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:612) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:232) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:213) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:117) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

at org.jboss.weld.event.TransactionalObserverNotifier.notifyObserver(TransactionalObserverNotifier.java:44) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:85) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:80) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

at org.jboss.weld.event.EventImpl.fire(EventImpl.java:69) [weld-core-1.1.16.Final-redhat-1.jar:1.1.16.Final-redhat-1]

at qa.qmic.wavetraf.backend.quartz.DeviceStatusJob.execute(DeviceStatusJob.java:39) [wavetraf-backend-1.2.4.jar:]

at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-2.2.1.jar:]

... 1 more

Any help on fixing this issue ???

Thanks

Hi,

Looks to me that you are trying to modify some Vaadin UI directly from quartz scheduler thread. How are you doing that? Are you wrapping the execution to UI.access method? That thread don’t have an easy way to detect the http session or the Vaadin UI.

cheers,
matti

Hi,

My application is using the MVP design within the CDI addon (built on top on this example https://github.com/peterl1084/cdiexample)

From my Job class, I fire an event that catched by mu UI view and where I got data from the Presenter and display results on the UI. The UI update uses the UI.access method to display new data.

Looking at the stacktrace and Vaadin CDI sources, some threadlocals seems to be badly set. Any change to create a small usage example for the use case? That would help a lot our CDI maintainer to do the correct fix.

cheers,
matti

OK I will try to create one from the above vaadin cdi example

Thanks

Hi Matti,

Please find attached a test example where I have tried to integrate the Quartz framework and where I have faced the above issues.
19931.zip (189 KB)

So you are trying to catch events (RefreshEvent) emitted by QuartzJob directly in you UI instances? I can ask our CDI maintainer to look into this, but I think this is just not possible. As a workaround you could create a Set of your VaadinUI’s to your QuarzJob and notify them directly from there. Maintaining that set could happen with CDI events.

cheers,
matti

Hi Matti,

is there any other better way to integrate the Quartz framework with the Vaadin CDI addon ??
I have also tried to extends an UI presenter class to a Quartz Job but again I have a CDI data session invalid.

Hi,

I have tried another tutorial on this blog:
http://vijaykiran.com/2013/01/a-quick-way-to-integrate-seam3-cdi-and-quartz-jobs/

and the now it works without any issues. I don’t know what is the difference, but it works for me.

Cool, I’d be nice if you could create an example application to github!?

cheers,
matti

Hi
Yes of course I will do it :slight_smile:
I will update the above attached project example and posted on Github

Perfect, I’ll include that in next Community Spotlight.

cheers,
matti

It will be really nice if yould post link to github here as integration with Quartz or other scheduling framework will be usefull for me as well.