0

我想在 nuxeo IDE 中安排一个事件,但我收到错误 java.lang.ClassCastException:

org.nuxeo.ecm.core.event.impl.EventContextImpl 无法转换为 org.nuxeo.ecm.core.event.impl.DocumentEventContext。

我的调度程序贡献是:

<?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>user_created</eventId>
 <eventCategory>default</eventCategory>

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

</component>

我的听众贡献是:

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

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

    <listener name="schedulelistener" async="false" postCommit="true"
      class="org.nuxeo.sample.ScheduleListener" priority="140">
      <event>user_created</event>
    </listener>
  </extension>

</component>

我的侦听器Java类是:

/**
 * 
 */

package org.nuxeo.sample;

import org.nuxeo.ecm.core.event.EventListener;
import org.nuxeo.ecm.core.event.Event;





/**
 * @author Parul.Puri01
 */


public class ScheduleListener implements EventListener {

    public void handleEvent(Event event){
        try{
            if(event!=null && event.getName().equals("user_created")){
                System.out.println("parul");
            }
            System.out.println("not an event");
       }
        catch (Exception e){
            e.printStackTrace();

        }


    }

}

错误是:

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)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
2016-06-02 12:13:01,047 WARN  [Nuxeo-Work-default-3] [org.nuxeo.ecm.platform.ec.notification.NotificationEventListener] Can not handle notification on a event that is not bound to a DocumentEventContext

请让我知道如何在 nuxeo IDE 中创建侦听器扩展点。我将它创建为文档侦听器。如何解决错误?

4

1 回答 1

2

user_created eventId 在文档上下文中由 Nuxeo 平台内部使​​用

因此,您不能使用没有 Document 上下文的调度程序触发相同的事件。

如果您想让您的示例工作,只需将user_created重命名为my_user_created或其他名称。

最好的,

于 2016-06-02T12:49:58.530 回答