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

ProcessService bean does not exist?

Tom Dostalik August 15, 2016

Following https://developer.atlassian.com/bamboodev/bamboo-tasks-api/executing-external-processes-using-processservice I would like to invoke some command using ProcessService bean. The injection as described in the link, does not work. 

I checked the source of several other plugins at Bitbucket, but each is using the concept as described in the link.

My class:

...
import com.atlassian.bamboo.process.ProcessService;
...
public class CheckTask implements TaskType {
	private final ProcessService processService;
	public CheckTask(@NotNull final ProcessService processService) {
		this.processService = processService;
	}

However Bamboo does not find the ProcessService bean and fail with following:

(org.springframework.beans.factory.UnsatisfiedDependencyException : Error creating bean with name 'bamboo.tasks.CheckTask': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.bamboo.process.ProcessService]: : No qualifying bean of type [com.atlassian.bamboo.process.ProcessService] 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.process.ProcessService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {})

Am I missing something ?

Bamboo version: 5.13.0
AMPS version:    6.2.6

4 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Tom Dostalik August 16, 2016

The solution in the end was quite simple, no oficial docs discuss the solution though. Hope this helps you a bit.
Finally thanks to this post I made it work:https://answers.atlassian.com/questions/33141765/testcollationservice-not-injected-into-tasktype-constructor-on-sdk-bamboo

import com.atlassian.bamboo.process.ProcessService;
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;

@Scanned
public class CheckTask implements TaskType {
	
	@ComponentImport
	private final ProcessService processService;

	public CheckTask(@NotNull final ProcessService processService) {
		this.processService = processService;
	}

The rest of the project was basicaly default, as generated by atlas-create-bamboo-plugin.

Krystian Brazulewicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 17, 2016

Using atlassian-spring-scanner (annotations Scanned and ComponentImport) is preferred way to do it. You might also use field injection and skip constructor altogether:

@Autowired @ComponentImport private ProcessService processService;
Tom Dostalik August 17, 2016

Using injection on private fields is discouraged, as it is hiding dependencies and makes testing more complicated etc. http://olivergierke.de/2013/11/why-field-injection-is-evil/ or  https://www.petrikainulainen.net/software-development/design/why-i-changed-my-mind-about-field-injection/

Krystian Brazulewicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 2, 2016

WRT testing: Mockito handles injection on private fields pretty well (but I agree that it is more straightforward when you use constructor injection).

Also if my dependencies are marked with dedicated annotation then how can you say I'm hiding them?

Tom Dostalik September 4, 2016

Private fields are not public API, that is what I mean by hiding. You have to check someone elses source code to check for the deps, which is also not always possible. Of course, we've got decompilers .. but ... If all mandatory dependencies are part of the constructor, you just can't miss them. See what I mean? But I guess this is a topic for a different place smile. Thanks for help. Cheers!

0 votes
Tom Dostalik August 16, 2016

Downloaded your SDK few days ago and generated my plugin using the atlas-create-bamboo-plugin. That version was generated by that command inside the pom.xml.

0 votes
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 16, 2016

How do you use unreleased Bamboo version, 5.13.0 is coming at the end of August 2016.

0 votes
Alexey Chystoprudov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 16, 2016

Do you have component-import of ProcessService in atlassian-plugin.xml?

<component-import key="processService" interface="com.atlassian.bamboo.process.ProcessService" />
Tom Dostalik August 16, 2016

Thanks for your help, I tried that one. The plugin build then unfortunately fails with: atlassian-plugin.xml contains a definition of component-import. This is not allowed when Atlassian-Plugin-Key is set.

The Atlassian-Plugin-Key part was generated by the atlas-create-bamboo-‌plugin.

I have found another solution though. Will post the answer right away.

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