I have my JIRA plugin separated out into a few different Maven projects, one with JIRA-agnostic core code, one with common JIRA integration code, and a JIRA plugin project (i.e. using Atlassian SDK for building/testing) with deployment-specific customization, with dependencies on the other projects. I am using Spring in the non-JIRA plugin projects without any issues. However, when testing my plugin in the refapp (via call to atlas-run or atlas-debug), I am getting failures during initialization due to null pointers; stepping through the code reveals that any dependency that is to be populated via the Autowire annotation is NOT getting set. My Spring config works fine in the framework projects (I have a decent test framework in place). I have just today started to dig into the docs regarding mixing Spring config in with the Atlassian Plugin config XML, and I believe I have all as it should be (from https://developer.atlassian.com/display/PLUGINFRAMEWORK/Advanced+Configuration+with+Spring+XML+Files and related articles). Now, I know that one solution is to go in and manually set ALL properties explicitly in the Spring config, but this REALLY defeats the awesomeness of the Autowire mechanism. Any help here is appreciated....
Community moderators have prevented the ability to post new answers.
I added the following line to the top of my Spring config in my JIRA Plugin project:
<context:annotation-config />
To be able to use @Autowired you have to:
enable spring auto-scan in /META-INF/spring/*.xml file with:
<context:component-scan base-package="foo.bar.package" /> <context:annotation-config />
In above xml file, remember to add parameter to <beans /> tag: default-autowire="autodetect"
If referencing JIRA-container bean ex. com.atlassian.jira.security.JiraAuthenticationContext, it would be good to add it's import to above file:
<osgi:reference id="authenticationContext" interface="com.atlassian.jira.security.JiraAuthenticationContext"/>
You may hopefully inject external components with OSGI annotation though, still by annotating setter: @org.springframework.osgi.extensions.annotation.ServiceReference
You may also be interested in this plugin: https://bitbucket.org/atlassian/atlassian-spring-scanner
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.