Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

TestCollationService not injected into TaskType constructor on SDK Bamboo

Jared Hicks January 5, 2016

I'm trying to develop a Bamboo plugin using the Atlassian SDK. I've followed the instructions (https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/set-up-the-sdk-prerequisites-for-linux-or-mac) to install the SDK on a VM:

vagrant@precise32:~/plugin/bamboo-test-task$ atlas-version
ATLAS Version:    6.2.2
ATLAS Home:       /usr/share/atlassian-plugin-sdk-6.2.2
ATLAS Scripts:    /usr/share/atlassian-plugin-sdk-6.2.2/bin
ATLAS Maven Home: /usr/share/atlassian-plugin-sdk-6.2.2/apache-maven-3.2.1
AMPS Version:     6.2.1
--------
Executing: /usr/share/atlassian-plugin-sdk-6.2.2/apache-maven-3.2.1/bin/mvn --version -gs /usr/share/atlassian-plugin-sdk-6.2.2/apache-maven-3.2.1/conf/settings
.xml
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T17:37:52+00:00)
Maven home: /usr/share/atlassian-plugin-sdk-6.2.2/apache-maven-3.2.1
Java version: 1.8.0_66, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: ISO-8859-1
OS name: "linux", version: "3.2.0-23-generic-pae", arch: "i386", family: "unix"

 

and then attempted to test my plugin with atlas-run:

vagrant@precise32:~$ git clone https://github.com/jaredhicks/bamboo-test-task.git
vagrant@precise32:~$ cd bamboo-test-task
vagrant@precise32:~$ atlas-run

 

The plugin was created by running atlas-create-bamboo-plugin and then adding a test task as described in:

The latter link suggests that spring should auto-wire the constructor dependencies and provide an implementation of TestCollationService from the application context.

 

When I create a build plan that includes my new task, it fails to run:

Failed to execute the build 'CAASDDB-TEST-JOB1-1'
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testTask.TestTask': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.bamboo.build.test.TestCollationService]: : No qualifying bean of type [com.atlassian.bamboo.build.test.TestCollationService] 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 qualifying bean of type [com.atlassian.bamboo.build.test.TestCollationService] 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:749)
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1139)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1042)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:342)
        at sun.reflect.GeneratedMethodAccessor132.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.atlassian.plugin.osgi.spring.DefaultSpringContainerAccessor.createBean(DefaultSpringContainerAccessor.java:97)
        at com.atlassian.plugin.module.ClassPrefixModuleFactory.createModule(ClassPrefixModuleFactory.java:35)
        at com.atlassian.plugin.module.PrefixDelegatingModuleFactory.createModule(PrefixDelegatingModuleFactory.java:88)
        at com.atlassian.bamboo.plugin.descriptor.AbstractBambooModuleDescriptor.createModule(AbstractBambooModuleDescriptor.java:30)
        at com.atlassian.bamboo.plugin.descriptor.AbstractBambooModuleDescriptor.access$000(AbstractBambooModuleDescriptor.java:17)
        at com.atlassian.bamboo.plugin.descriptor.AbstractBambooModuleDescriptor$2.call(AbstractBambooModuleDescriptor.java:104)
        at com.atlassian.bamboo.plugin.BambooPluginUtils.callUnsafeCode(BambooPluginUtils.java:132)
        at com.atlassian.bamboo.plugin.descriptor.AbstractBambooModuleDescriptor.getModule(AbstractBambooModuleDescriptor.java:113)
        at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:241)
        at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:108)
        at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:74)
        at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:196)
        at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:132)
        at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:123)
        at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:215)
        at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:122)
        at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:118)
        at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:49)
        at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:31)
        at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:20)
        at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:52)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.bamboo.build.test.TestCollationService] 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:1301)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
        at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
        ... 31 more

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Jared Hicks January 29, 2016

Annotations must be added to configure the dependency injection. In the original example, you must

  1. Add the @Scanned annotation to your task class:

    @Scanned
    public class TestTask implements TaskType {
    ...
  2. Add the correct annotations to your injectable constructor:

    @Autowired
    public TestTask(@ComponentImport final ProcessService processService) {
    ...

After adding these annotations, all the correct dependencies were injected and the task worked as expected.

Tom Dostalik August 16, 2016

You just made my day! Finally after two days of different hacks and whatever solutions I came across this post. Cheers!

0 votes
Jared Hicks January 29, 2016

Sorry, forgot to add the github link. I tried to modify the template as little as possible. Note that I changed the dependency from TestCollationService to ProcessService in the process of answering my question.

0 votes
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2016

Can you show your pom.xml and atlassian-plugin.xml? You may have a missing dependency.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events