06-02-2016 11:18 PM
the scheduler contribution is:
<?xml version="1.0"?>
<component name="org.nuxeo.sample.ScheduleCall" version="1.0">
<extension target="org.nuxeo.ecm.core.scheduler.SchedulerService"
point="schedule">
<schedule id="testschedule">
<username>Administrator</username>
<eventId>my_user_created</eventId>
<eventCategory>default</eventCategory>
<cronExpression>0 1 * * * ?</cronExpression>
</schedule>
</extension>
</component>
the listener contribution is:
<component name="org.nuxeo.sample.listener.contrib.ScheduleListener">
<extension target="org.nuxeo.ecm.core.event.EventServiceComponent"
point="listener">
<listener name="schedulelistener" async="false" postCommit="false"
class="org.nuxeo.sample.ScheduleListener" priority="100">
<event>my_user_created</event>
</listener>
</extension>
</component>
The listener java class is:
package org.nuxeo.sample;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.NuxeoException;
import org.nuxeo.ecm.core.event.Event;
import org.nuxeo.ecm.core.event.EventContext;
import org.nuxeo.ecm.core.event.EventListener;
import org.nuxeo.ecm.core.event.impl.DocumentEventContext;
public class ScheduleListener implements EventListener {
public void handleEvent(Event event) throws ClientException {
try{
EventContext ctx = event.getContext();
if (!(ctx instanceof DocumentEventContext)) {
return;
}
DocumentModel doc = ((DocumentEventContext)ctx).getSourceDocument();
if(doc==null){
return;
}
String doctype = doc.getType();
System.out.println("*******"+doctype);
}
catch (Exception e){
e.printStackTrace();
}
}
}
The error is:
2016-06-03 11:47:01,005 ERROR [Quartz_Worker-1] [org.nuxeo.ecm.core.event.impl.EventServiceImpl] Exception during timezoneSelector sync listener execution, continuing to run other listeners
java.lang.ClassCastException: org.nuxeo.ecm.core.event.impl.EventContextImpl cannot be cast to org.nuxeo.ecm.core.event.impl.DocumentEventContext
at org.nuxeo.ecm.user.center.profile.localeProvider.UserLocaleSelectorListener.handleEvent(UserLocaleSelectorListener.java:43)
at org.nuxeo.ecm.core.event.impl.EventServiceImpl.fireEvent(EventServiceImpl.java:200)
at org.nuxeo.ecm.core.scheduler.EventJob.execute(EventJob.java:119)
at org.nuxeo.ecm.core.scheduler.EventJob.execute(EventJob.java:65)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
2016-06-03 11:47:01,008 WARN [Nuxeo-Work-default-4] [org.nuxeo.ecm.platform.ec.notification.NotificationEventListener] Can not handle notification on a event that is not bound to a DocumentEventContext
06-06-2016 09:13 AM
Have you investigated this further?
java.lang.ClassCastException: org.nuxeo.ecm.core.event.impl.EventContextImpl cannot be cast to org.nuxeo.ecm.core.event.impl.DocumentEventContext
I believe your problem is here, as I'm sure you are aware:
DocumentModel doc = ((DocumentEventContext)ctx).getSourceDocument();
Seems as though you should be specifying an index because the event data is exposed as a list of arguments. Does that many any sense?
See the source code:
http://community.nuxeo.com/api/nuxeo/5.4/javadoc/org/nuxeo/ecm/core/event/EventContext.html
Hope this helps!
-Y
06-06-2016 10:23 PM
Thank you, yes the error lies on this line only. My IDE wasn't appropriately configured so now this error is gone but I am unable to get any output now. I just want to see if the output is printed after regular intervals. Please let me know if you can help with this error
06-07-2016 12:19 PM
Hey Parul,
06-08-2016 05:35 AM
The server log says there is an error with calling nuxeo online services but I don't know if it has anything to do with my code
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.