No matching bean of type [com.intellij.util.EventDispatcher] for agent lifecycle listener

Hi all,

I created the following class in agent plugin code:

public class TFAgentListener extends AgentLifeCycleAdapter {
  private ExtensionHolder extensionHolder;

  public TFAgentListener(@NotNull EventDispatcher<TFAgentListener> dispatcher,
                                 @NotNull ExtensionHolder extensionHolder) {
    this.extensionHolder = extensionHolder;
    dispatcher.addListener(this);
  }

  @Override
  public void beforeBuildFinish(@NotNull AgentRunningBuild build, @NotNull BuildFinishedStatus buildStatus) {
      ....
   }


And added it to

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:lang="http://www.springframework.org/schema/lang" xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://www.springframework.org/schema/lang
                           http://www.springframework.org/schema/lang/spring-lang-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
       default-autowire="constructor">

  <bean name="TFAgentListener" /> //<--- here
  <bean name="TFRunner" />

</beans>



When I put plugin to .Buildserver/plugins folder and restart TeamCity I receive the following stacktrace:

[2014-02-12 18:49:52,844]  ERROR - gins.spring.SpringPluginLoader - Failed to initialize spring context for plugin tf

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'TFAgentListener' defined in plugin: tf#tf.jar!/META-INF/build-agent-plugin-tf.xml: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.intellij.util.EventDispatcher]: : No matching bean of type [com.intellij.util.EventDispatcher] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.intellij.util.EventDispatcher] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

 at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:730)

 at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:196)

 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)

 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)

 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)

 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)

 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)

 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)

 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)

 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)

 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)

 at jetbrains.buildServer.plugins.spring.SpringPluginLoader.pluginClassesLoaded(SpringPluginLoader.java:72)

 at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)

 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

 at java.lang.reflect.Method.invoke(Method.java:597)

 at jetbrains.buildServer.util.EventDispatcher.dispatch(EventDispatcher.java:115)

 at jetbrains.buildServer.util.EventDispatcher$2.invoke(EventDispatcher.java:67)

 at com.sun.proxy.$Proxy7.pluginClassesLoaded(Unknown Source)

 at jetbrains.buildServer.plugins.PluginManagerImpl$2.visitPlugin(PluginManagerImpl.java:122)

 at jetbrains.buildServer.plugins.PluginsCollection.foreachLoadedPlugins(PluginsCollection.java:107)

 at jetbrains.buildServer.plugins.PluginManagerImpl.firePluginClassesLoaded(PluginManagerImpl.java:120)

 at jetbrains.buildServer.plugins.PluginManagerImpl.loadPlugins(PluginManagerImpl.java:80)

 at jetbrains.buildServer.agent.plugins.AgentPluginsLoader.initializePlugins(AgentPluginsLoader.java:63)

 at jetbrains.buildServer.agent.AgentMain2.loadPlugins(AgentMain2.java:140)

 at jetbrains.buildServer.agent.AgentMain2.main(AgentMain2.java:41)

 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

 at java.lang.reflect.Method.invoke(Method.java:597)

 at jetbrains.buildServer.agent.AgentMain.main(AgentMain.java:41)

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.intellij.util.EventDispatcher] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

 at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920)

 at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789)

 at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)

 at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:795)

 at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723)

 ... 31 more

Can you please give me some direction for fixing this problem?

Thank you

5 comments
Comment actions Permalink

Igor, 


Obviously there is no bean of type EventDispatcher<TFAgentListener> available in the context.

As far as I understand, you are trying to implement your AgentLifeCycleListener and attach it.

So you need to use bean of type EventDispatcher<AgentLifeCycleListener> like this
public TFAgentListener(@NotNull final EventDispatcher<AgentLifeCycleListener> dispatcher,
                                 @NotNull final ExtensionHolder extensionHolder) {
    this.extensionHolder = extensionHolder;
    dispatcher.addListener(this);
  }
0
Comment actions Permalink

Thank you for your answer, but I still receive absolutely the same error:

Unsatisfied dependency expressed through constructor argument with index 0 of type [com.intellij.util.EventDispatcher]: : No matching bean of type [com.intellij.util.EventDispatcher] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.intellij.util.EventDispatcher] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

0
Comment actions Permalink

Sorry, I did missed the package name in your error message.

Please, check your imports. You should be using jetbrains.buildServer.util.EventDispatcher, not com.intellij.util.EventDispatcher

0
Comment actions Permalink

Now it works. Thank you for your help

0

Please sign in to leave a comment.