Hello, I’m really lost here, so please if anyone have any advice to test, I’d be greatful :).
I have one p2 plugin (plugin A) which use Java Spring configuration and java objects are
package cz.morosystems.jira.tm.pmo.cf.controllingobjects.service;
...
public interface ControllingObjectsService {...}
package cz.morosystems.jira.tm.pmo.cf.controllingobjects.service.impl;
...
public class ControllingObjectsServiceImpl implements ControllingObjectsService {...}
spring configuration:
@Bean
public ControllingObjectsService controllingObjectsService(...some dependencies...) {
return new ControllingObjectsServiceImpl(...some dependencies...);
}
@SuppressWarnings("rawtypes")
@Bean
public FactoryBean<ServiceRegistration> exportControllingObjectsService(
final ControllingObjectsService controllingObjectsService) {
ExportOptions options = ExportOptions.as(ControllingObjectsService.class);
return exportOsgiService(controllingObjectsService, options);
}
pom.xml looks like:
<Export-Package>
cz.morosystems.jira.tm.pmo.cf.controllingobjects.service
</Export-Package>
This plugin starts succesfully.
I have second plugin (plugin B) which uses spring scanner (not java config):
package cz.morosystems.jira.tm.pmo.services.facade;
...
import com.atlassian.plugin.spring.scanner.annotation.export.ExportAsService;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import cz.morosystems.jira.tm.pmo.cf.controllingobjects.service.ControllingObjectsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
...
@Component
@ExportAsService
public class ControllingObjectFacadeImpl implements ControllingObjectFacade {
...
@Autowired
public ControllingObjectFacadeImpl(@ComponentImport @NonNull final ControllingObjectsService controllingObjectsService, ... other dependencies...) {
this.controllingObjectsService = controllingObjectsService;
}
jira maven plugin instructions configuration in pom.xml looks like:
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<Export-Package>
...
</Export-Package>
<Import-Package>
cz.morosystems.jira.tm.pmo.cf.controllingobjects.service.*,
...
*;resolution:="optional"
</Import-Package>
<Spring-Context>*</Spring-Context>
</instructions>
This plugin B and its ControllingObjectFacadeImpl component is initialized correctly (tested in Script runner console).
And I have third plugin (C) which uses spring scanner and implements REST API endpoint:
package cz.morosystems.jira.tm.pmo.restapi.service;
...
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import cz.morosystems.jira.tm.pmo.cf.controllingobjects.service.ControllingObjectsService;
import javax.inject.Inject;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
...
@Component
@Path("/controllingobjectsadministration")
@Produces({MediaType.APPLICATION_JSON})
public class ControllingObjectsAdministrationRest {
private final ControllingObjectsService controllingObjectsService;
@Inject
public ControllingObjectsAdministrationRest(@ComponentImport @NonNull final ControllingObjectsService controllingObjectsService) {
this.controllingObjectsService = controllingObjectsService;
}
jira maven plugin instructions configuration in pom.xml looks like:
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<Export-Package>cz.morosystems.jira.tm.pmo.restapi</Export-Package>
<Import-Package>
...
cz.morosystems.jira.tm.pmo.cf.controllingobjects.service,
...
*;resolution:="optional"
</Import-Package>
<Spring-Context>*</Spring-Context>
</instructions>
This plugin installation fails with following exception and I have no idea why it is not working. Do you have any idea what should I check Thank you very much:
2025-04-10 09:43:34,460+0200 ThreadPoolAsyncTaskExecutor::Thread 45 ERROR [c.a.p.osgi.factory.OsgiPlugin] Unable to start the plugin container for plugin 'cz.morosystems.jira.tmobile-pmo-rest-api'
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controllingObjectsAdministrationRest': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cz.morosystems.jira.tm.pmo.cf.controllingobjects.service.ControllingObjectsService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport("")}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:794)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:220)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:209)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:57)
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:322)
at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:287)
at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cz.morosystems.jira.tm.pmo.cf.controllingobjects.service.ControllingObjectsService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport("")}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:904)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:781)
... 19 more
2025-04-10 09:43:34,462+0200 ThreadPoolAsyncTaskExecutor::Thread 45 ERROR [o.e.g.b.e.internal.support.ExtenderConfiguration] Application context refresh failed (NonValidatingOsgiBundleXmlApplicationContext(bundle=cz.morosystems.jira.tmobile-pmo-rest-api, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controllingObjectsAdministrationRest': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cz.morosystems.jira.tm.pmo.cf.controllingobjects.service.ControllingObjectsService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport("")}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:794)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:220)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:336)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:334)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:209)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:57)
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:322)
at org.eclipse.gemini.blueprint.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org.eclipse.gemini.blueprint.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:287)
at org.eclipse.gemini.blueprint.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:137)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cz.morosystems.jira.tm.pmo.cf.controllingobjects.service.ControllingObjectsService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport("")}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:904)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:781)
... 19 more
When I try to change the implementation to following, it works fine but I don’t like these hacks just because I don’t know what’s the real problem:
@Inject
public ControllingObjectsAdministrationRest() {
this.controllingObjectsService = ComponentAccessor.getOSGiComponentInstanceOfType(ControllingObjectsService.class);
}