How to make an event listener in nuxeo IDE

I am trying to schedule an event in nuxeo IDE but facing error while creating event listener in IDE:

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"
 <schedule id="testschedule">

 <cronExpression>0 1 * * * ?</cronExpression>

the listener contribution is:

<component name="org.nuxeo.sample.listener.contrib.ScheduleListener">

  <extension target="org.nuxeo.ecm.core.event.EventServiceComponent"

    <listener name="schedulelistener" async="false" postCommit="false"
      class="org.nuxeo.sample.ScheduleListener" priority="100">



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 {

            EventContext ctx = event.getContext();
            if (!(ctx instanceof DocumentEventContext)) {

            DocumentModel doc = ((DocumentEventContext)ctx).getSourceDocument();

            String doctype = doc.getType();


        catch (Exception e){



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.core.event.impl.EventServiceImpl.fireEvent(
    at org.nuxeo.ecm.core.scheduler.EventJob.execute(
    at org.nuxeo.ecm.core.scheduler.EventJob.execute(
2016-06-03 11:47:01,008 WARN  [Nuxeo-Work-default-4] [] Can not handle notification on a event that is not bound to a DocumentEventContext
0 votes

1 answers



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:

Hope this helps!


0 votes

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

Hey Parul,

Are you debugging? Maybe throw some print statements before your return statements? Or, try the for loop, or similar:

    for (Object arg : ctx.getArguments()) {

        if (arg instanceof DocumentModel) {
            DocumentModel doc = (DocumentModel) arg;

            String doctype = doc.getType( );


Have you checked the server log for any warnings? That might be a good place to start.



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

Hi Parul,

Going to your log directory in the nuxeo directory, do tail -f server.log (this command is your friend, you'll be using it a lot, trust me) from the command line in your terminal, assuming you're using Ubuntu.

Trigger the event on the platform that the listener is listening to, and simultaneously watch the output of the server log in your terminal window.

If you get any online services errors or warnings (or anything else for that matter), that is likely your problem, or one of them.

If you can, please post the errors or warnings you are getting, as it would make all of our lives easier.

Good luck,