Build agent cannot start due to NoUniqueBeanDefinitionExcepton on ArtifactStorageSettingsProvider

When trying to launch an agent on the same machine as our Teamcity server, it fails with an error about there being 2 instances of ArtifactStorageSettingsProvider:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jetbrains.buildServer.agent.impl.artifacts.ArtifactsPublisherProviderImpl#0' defined in URL [jar:file:/C:/TeamCity/buildAgent/lib/agent.jar!/META-INF/buildAgentSpring.xml]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'jetbrains.buildServer.artifacts.ArtifactStorageSettingsProvider' available: expected single matching bean but found 2: jetbrains.buildServer.agent.impl.storage.ArtifactStorageSettingsProviderImpl#0,jetbrains.buildServer.agent.impl.storage.ArtifactStorageSettingsProviderImpl#1
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1196) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1098) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:757) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) ~[restore.spring.jar:4.3.28.RELEASE]
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93) ~[restore.spring.jar:4.3.28.RELEASE]
    at jetbrains.buildServer.agent.AgentMain2$3.<init>(AgentMain2.java:161) ~[agent.jar:?]
    at jetbrains.buildServer.agent.AgentMain2.createRootApplicationContext(AgentMain2.java:152) ~[agent.jar:?]
    at jetbrains.buildServer.agent.AgentMain2.main2(AgentMain2.java:87) ~[agent.jar:?]
    at jetbrains.buildServer.agent.AgentMain2.main(AgentMain2.java:39) ~[agent.jar:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    at jetbrains.buildServer.agent.AgentMain.main(AgentMain.java:43) ~[agent.jar:?]


This may be a result of having installed, then uninstalled, a second Teamcity instance in order to copy over its jre folder as a suggested fix to a different error. How can I remove the duplicate bean? 

Please sign in to leave a comment.