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

UnsatisfiedDependencyException/NoSuchBeanDefinitionException for ao service

Jeff Morgan August 25, 2016

Hey guys,

I added another ao entity to my plug-in and did it exactly the way I did it before, but this time it's not working.

The error I got is:

 

[INFO] [talledLocalContainer] 2016-08-25 11:46:13,464 http-nio-2990-exec-4 ERROR admin 706x629x1 1m3eyry 0:0:0:0:0:0:0:1 /secure/Settings.jspa [c.a.j.web.dispatcher.JiraWebworkActionDispatcher] Exception thrown from action 'Settings', returning 404
[INFO] [talledLocalContainer] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.example.webwork.Settings': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.example.db.xyService]: : No qualifying bean of type [com.example.db.xyService] 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.example.db.xyService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1139)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1042)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:342)
[INFO] [talledLocalContainer]   ... 2 filtered
[INFO] [talledLocalContainer]   at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.osgi.spring.DefaultSpringContainerAccessor.createBean(DefaultSpringContainerAccessor.java:97)
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.JiraActionFactory$JiraPluginActionFactory.getActionImpl(JiraActionFactory.java:389)
[INFO] [talledLocalContainer]   at webwork.action.factory.PrefixActionFactoryProxy.getActionImpl(PrefixActionFactoryProxy.java:99)
[INFO] [talledLocalContainer]   at webwork.action.factory.JspActionFactoryProxy.getActionImpl(JspActionFactoryProxy.java:59)
[INFO] [talledLocalContainer]   at webwork.action.factory.CommandActionFactoryProxy.getActionImpl(CommandActionFactoryProxy.java:60)
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.LookupAliasActionFactoryProxy.getActionImpl(LookupAliasActionFactoryProxy.java:61)
[INFO] [talledLocalContainer]   at webwork.action.factory.CommandActionFactoryProxy.getActionImpl(CommandActionFactoryProxy.java:60)
[INFO] [talledLocalContainer]   at webwork.action.factory.ContextActionFactoryProxy.getActionImpl(ContextActionFactoryProxy.java:36)
[INFO] [talledLocalContainer]   at webwork.action.factory.PrepareActionFactoryProxy.getActionImpl(PrepareActionFactoryProxy.java:37)
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.JiraActionFactory$SafeParameterSettingActionFactoryProxy.getActionImpl(JiraActionFactory.java:147)
[INFO] [talledLocalContainer]   at webwork.action.factory.ChainingActionFactoryProxy.getActionImpl(ChainingActionFactoryProxy.java:53)
[INFO] [talledLocalContainer]   at com.atlassian.jira.config.webwork.JiraActionFactory.getActionImpl(JiraActionFactory.java:301)
[INFO] [talledLocalContainer]   ... 2 filtered
[INFO] [talledLocalContainer]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
[INFO] [talledLocalContainer]   ... 74 filtered
[INFO] [talledLocalContainer]   at com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59)
[INFO] [talledLocalContainer]   ... 38 filtered
[INFO] [talledLocalContainer]   at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70)
[INFO] [talledLocalContainer]   ... 90 filtered
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[INFO] [talledLocalContainer]   at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
[INFO] [talledLocalContainer]   at java.lang.Thread.run(Thread.java:745)
[INFO] [talledLocalContainer] Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.example.db.xyService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)

 

But the code does not differ from the other ao services.

[...]
@Component
public class xyServiceImpl implements xyService {

    private final ActiveObjects ao;

    @Autowired
    public xyServiceImpl(@ComponentImport ActiveObjects ao) {
        this.ao = checkNotNull(ao);
    }
[...]
[...]
public class Settings extends JiraWebActionSupport {
    private final xyService yService;
    public Settings(xyService yService) {
        this.yService = checkNotNull(yService);
    }
[...]

 

What is wrong here?

 

 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Volodymyr Krupach
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.
August 25, 2016

Did you try "atlas-clean"? I have to run it every 2-3 days when continuously working under one addon.

You may want to keep your "testing db" before cleaning the project:

  • copy /target/jira/home/database/h2db.mv.db and replace generated db after atlas-run or atlas-debug.
  • Launch your addon via atlas-run or atlas-debug.
  • stop the addon by Ctrl+C
  • replace the generated db with your copy

You can try to replace the db while the addon starts by constantly refreshing the "target" folder and replacing the db file right after it appears.

=== Update ===

I seldom use Atlassian scanner approach (IMHO: it's odd and raw, and in case you recently started atlassain addons developemnt: the old apporach is to declare all components and imports through tags in atlassian-plugin.xml) but I guess you miss @Scanned annotation for the class @Autowired for the constructor:

[...]
@Scanned
public class Settings extends JiraWebActionSupport {
    private final xyService yService;
    @Autowired
    public Settings(xyService yService) {
        this.yService = checkNotNull(yService);
    }
[...]
Jeff Morgan August 25, 2016

Hi Volodymyr,

yes I did. In fact I did it many times... I shut down the server, cleaned the project and checked everything - I even rewrote the java files from scratch but it doesn't make any difference. The error seems to be an annotation error, but it's exactly the same as in my other working classes .

Jeff Morgan August 25, 2016

I added @Scanned and @Autowired and it does not change anything... the error is literally the same.

Volodymyr Krupach
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.
August 25, 2016

Should work. Try injecting other service that work for other actions so you will know if the problem is in service or in action class. And vice versa - inject the service into action that works with other srvices.

Jeff Morgan August 25, 2016

OK, so the problem was definitely in the webwork. the service worked within the other webworks - even without the @Scanned / @Autowired annotations. I rewrote the webwork parts and it seems to work now, even though I have no idea what the game-changing part is.

You don't coincidentally know a solution for this problem here?

Thank you very much!

Volodymyr Krupach
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.
August 25, 2016

have to leave the office. Willanswer later form home.

TAGS
AUG Leaders

Atlassian Community Events