UnsatisfiedDependencyException java 11

@Preload
@Table("TEBuilds")
public interface BuildAOEntity extends Entity {
	Integer getBuildId();
	void setBuildId(Integer buildId);
	Date getDate();
	void setDate(Date date);
	@StringLength(StringLength.UNLIMITED)
	String getJsonData();
	void setJsonData(String jsonData);
}


@Component
@ComponentScan
public class StorageService {
	private final ActiveObjects ao;

	@Autowired
	public StorageService(@ComponentImport ActiveObjects ao) {
		this.ao = ao;
	}

	@Bean
	public BuildAOEntity createBuild(Integer buildId, String jsonData) {
		return ao.create(BuildAOEntity.class, createParam("BUILD_ID", buildId, jsonData));
	}
}

@Scanned
@Named("MyPlugin")
public class MyPlugin implements Macro {
	private final PluginSettingsFactory pluginSettingsFactory;
	private final StorageService storageService;

	@Autowired
	public MyPlugin(@ComponentImport PluginSettingsFactory pluginSettingsFactory, @ComponentImport StorageService storageService) {
		this.pluginSettingsFactory = pluginSettingsFactory;
		this.storageService = storageService;
	}

	@Override
	public String execute(Map<String, String> config, String linksContent, ConversionContext arg2) throws MacroExecutionException {
	....
	storageService.createBuild(11, "json is here");
	....
	}
}
<dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-plugin</artifactId>
            <version>${ao.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-confluence-spi</artifactId>
            <version>${ao.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>2.2.220</version>
            <scope>provided</scope>
        </dependency>
....
<properties>
        <confluence.version>7.18.1</confluence.version>
        <confluence.data.version>7.18.1</confluence.data.version>
        <amps.version>8.9.0</amps.version>
        <ao.version>3.6.3</ao.version>
        <plugin.testrunner.version>2.0.2</plugin.testrunner.version>
        <atlassian.spring.scanner.version>1.2.14</atlassian.spring.scanner.version>
        <!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
[INFO] [talledLocalContainer] 2023-09-18 14:49:20,354 ERROR [AtlassianEvent::CustomizableThreadFactory-4] [atlassian.plugin.module.PrefixDelegatingModuleFactory] createModule Detected an error instantiating the module via Spring. This usually means that you haven't created a <component-import> for the interface you're trying to use. https://developer.atlassian.com/x/TAEr  for more details.
[INFO] [talledLocalContainer] 2023-09-18 14:49:20,356 WARN [AtlassianEvent::CustomizableThreadFactory-4] [impl.macro.metadata.AllMacroMetadataCache] lambda$loadMacroMetadata$1 Failed to make metadata for module 'com.global.confluence.plugins.myplugin:myplugin-results': Error creating bean with name 'com.global.confluence.plugins.myplugin.api.MyPlugin': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.global.confluence.plugins.myplugin.activeObjects.StorageService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value="")}
[INFO] [talledLocalContainer] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.global.confluence.plugins.myplugin.api.MyPlugin': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.global.confluence.plugins.myplugin.activeObjects.StorageService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value="")}
[INFO] [talledLocalContainer] 	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)
[INFO] [talledLocalContainer] 	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)
[INFO] [talledLocalContainer] 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)
[INFO] [talledLocalContainer] 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)
[INFO] [talledLocalContainer] 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
[INFO] [talledLocalContainer] 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
[INFO] [talledLocalContainer] 	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:378)
[INFO] [talledLocalContainer] 	at jdk.internal.reflect.GeneratedMethodAccessor198.invoke(Unknown Source)

echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64
java -version
openjdk version “11.0.20.1” 2023-08-24
OpenJDK Runtime Environment (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

javac -version
javac 11.0.20.1

Is someone who can help me with this error?

1 Like

My solution

Pom.xml
update atlassina spring scanner to version 2.2.6
<atlassian.spring.scanner.version>2.2.6</atlassian.spring.scanner.version>
Instruction is here ( Common mistakes sections )
https://bitbucket.org/atlassian/atlassian-spring-scanner/src/master/

@Named
@Component
public class StorageService {

	private final ActiveObjects ao;

	@Autowired
	public StorageService(@ComponentImport ActiveObjects ao) {
		this.ao = ao;
	}

	public BuildAOEntity createBuild(Integer buildId, String jsonData) {
		return ao.create(BuildAOEntity.class, createParam("BUILD_ID", buildId, jsonData));
	}
@Named("MyPlugin")
@Component
public class MyPlugin implements Macro {
	private final PluginSettingsFactory pluginSettingsFactory;
	private final StorageService storageService;

	@Autowired
	public MyPlugin(@ComponentImport PluginSettingsFactory pluginSettingsFactory, StorageService storageService) {
		this.pluginSettingsFactory = pluginSettingsFactory;
		this.storageService = storageService;
	}

I have the same problem. Unfortunately, updating the spring scanner version did not help. I worked through the Common Mistakes in the link you provided, but to no avail.

The issue occurred after changing the compiler JDK from 1.8 to 11 (source and target are still 1.8 though).