坩埚:没有找到侦听器的侦听器调用程序

Crucible: No listener invokers were found for listener

我正在尝试捕捉评论状态事件,例如有人正在关闭它。并在从插件中获得任何生命迹象之后。向日志文件(从任何日志级别)或 STDOUT 发送一行。 atlassian-plugins.xml 看起来像这样:

 <component-import key="eventPublisher" interface="com.atlassian.event.api.EventPublisher"/>

<component key="reviewListenerNew" class="com.harman.ListenerNew.ReviewListenerNew">
    <description>Class that processes the incoming Review events.</description>
</component>

Class 本身在这里:

package com.harman.ListenerNew;
import com.atlassian.crucible.event.ReviewStateChangedEvent;
import com.atlassian.crucible.spi.data.ReviewData;
import com.atlassian.crucible.spi.services.ReviewService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class ReviewListenerNew implements InitializingBean, DisposableBean{
private final EventPublisher eventPublisher;
private final ReviewService reviewService;
private final ReviewManager reviewManager;
private final UserManager userManager;

private final Logger log = Logger.getLogger(ReviewListenerNew.class);

public ReviewListenerNew(EventPublisher eventPublisher, ReviewService reviewService, ReviewManager reviewManager, UserManager userManager){
    this.eventPublisher = eventPublisher;
    this.reviewService = reviewService;
    this.reviewManager = reviewManager;
    this.userManager = userManager;

}
public Class[] getHandledEventClasses() {
    return new Class[0];
}


public void handEvent(ReviewStateChangedEvent event) {
    if (event.getNewState().equals(ReviewData.State.Closed))
    {
        log.warn("Event occured" + event);
        log.info("Event occured" + event);
        log.info("Event occured" + event.getNewState());
        log.error("Event occured" + event);
        log.debug("Event occured" + event);
        System.out.println("Event: " + event);

    }
        return;

}

@Override
public void destroy() throws Exception {

    eventPublisher.unregister(this);
}

@Override
public void afterPropertiesSet() throws Exception {
    eventPublisher.register(this);
}
}

这可以成功构建和上传,但无法启动。错误信息是:

    2015-07-03 14:58:00,790 WARN  [UpmAsynchronousTaskManager:thread-1 ] com.atlassian.plugin.util.resource.AlternativeDirectoryResourceLoader AlternativeDirectoryResourceLoader-<init> - Resource directory , which resolves to C:\AtlasPlugins\standalon does not exist
2015-07-03 14:58:00,946 ERROR [ThreadPoolAsyncTaskExecutor::Thread 26 ] com.atlassian.plugin.osgi.factory.OsgiPlugin OsgiPlugin-onPluginContainerFailed - Unable to start the plugin container for plugin 'com.harman.ListenerNew.ListenerNew'
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reviewListenerNew' defined in URL [bundle://94.0:0/META-INF/spring/atlassian-plugins-components.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No listener invokers were found for listener <com.harman.ListenerNew.ReviewListenerNew@4b488637>
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.run(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access00(AbstractDelegatedExecutionApplicationContext.java:69)
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.run(AbstractDelegatedExecutionApplicationContext.java:355)
    at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
    at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: No listener invokers were found for listener <com.harman.ListenerNew.ReviewListenerNew@4b488637>
    at com.atlassian.event.internal.LockFreeEventPublisher$InvokerBuilder.build(LockFreeEventPublisher.java:271)
    at com.atlassian.event.internal.LockFreeEventPublisher.register(LockFreeEventPublisher.java:88)
    at com.atlassian.fisheye.event.FisheyeEventPublisher.register(FisheyeEventPublisher.java:43)
    at sun.reflect.GeneratedMethodAccessor83.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegistrar.java:129)
    at com.sun.proxy.$Proxy136.register(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
    at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
    at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at com.sun.proxy.$Proxy1255.register(Unknown Source)
    at com.harman.ListenerNew.ReviewListenerNew.afterPropertiesSet(ReviewListenerNew.java:110)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
    ... 19 more
2015-07-03 14:58:00,955 ERROR [ThreadPoolAsyncTaskExecutor::Thread 26 ] org.springframework.osgi.extender.internal.activator.ContextLoaderListener DefaultOsgiBundleApplicationContextListener-onOsgiApplicationEvent - Application context refresh failed (NonValidatingOsgiBundleXmlApplicationContext(bundle=com.harman.ListenerNew.ListenerNew, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reviewListenerNew' defined in URL [bundle://94.0:0/META-INF/spring/atlassian-plugins-components.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No listener invokers were found for listener <com.harman.ListenerNew.ReviewListenerNew@4b488637>
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.run(AbstractAutowireCapableBeanFactory.java:409)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:264)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access00(AbstractDelegatedExecutionApplicationContext.java:69)
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.run(AbstractDelegatedExecutionApplicationContext.java:355)
    at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
    at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
    at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: No listener invokers were found for listener <com.harman.ListenerNew.ReviewListenerNew@4b488637>
    at com.atlassian.event.internal.LockFreeEventPublisher$InvokerBuilder.build(LockFreeEventPublisher.java:271)
    at com.atlassian.event.internal.LockFreeEventPublisher.register(LockFreeEventPublisher.java:88)
    at com.atlassian.fisheye.event.FisheyeEventPublisher.register(FisheyeEventPublisher.java:43)
    at sun.reflect.GeneratedMethodAccessor83.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegistrar.java:129)
    at com.sun.proxy.$Proxy136.register(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
    at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
    at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
    at com.sun.proxy.$Proxy1255.register(Unknown Source)
    at com.harman.ListenerNew.ReviewListenerNew.afterPropertiesSet(ReviewListenerNew.java:110)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
    ... 19 more

还有一次 class 的尝试,例如:

package com.harman.ListenerNew;

import com.atlassian.crucible.event.ReviewStateChangedEvent;
import com.atlassian.crucible.spi.data.ReviewData;
import com.atlassian.crucible.spi.services.ReviewService;
import com.atlassian.event.api.EventPublisher;
import com.cenqua.crucible.model.Review;
import com.cenqua.crucible.model.managers.ReviewManager;
import com.cenqua.fisheye.user.UserManager;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import com.atlassian.event.api.EventListener;

public class ReviewListenerNew{
private final Logger log = Logger.getLogger(ReviewListenerNew.class);

public Class[] getHandledEventClasses() {
    return new Class[0];
}

@EventListener
public void handleEvent(ReviewStateChangedEvent event) {
    if (event.getNewState().equals(ReviewData.State.Closed))
    {
        log.warn("Event occured" + event);
        log.info("Event occured" + event);
        log.info("Event occured" + event.getNewState());
        log.error("Event occured" + event);
        log.debug("Event occured" + event);
        System.out.println("Event: " + event);

    }
        return;

}

}

但在这种情况下,这可以构建和上传,看起来甚至已经开始,但没有任何操作。

似乎关键组件必须是 eventListener:

 <component key="eventListener" class="com.harman.NewEventListener">
    <description>Class that processes the new Crucible event</description>
</component>