我想在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中创建侦听器扩展点。我正在创建它作为文档监听器。如何解决错误?
答案 0 :(得分:2)
user_created eventId由Nuxeo平台在文档上下文中内部使用。
因此,您无法使用没有文档上下文的调度程序触发此同一事件。
如果您想让您的示例正常工作,只需将 user_created 重命名为 my_user_created 或其他任何内容。
最佳,