Getting Error Injecting ActiveObjects
Asked by Frank:

I am trying to use Active Objects in a Confluence plugin. However, I get an error that ActiveObjects cannot be injected. (To speedup time, I currently am using the refapp version 5.2.4 locally.)

The tables for the entities are created in the database, Hence Active Objects is available and seems to have some basic functionality. For me, the error message indicates that the mapping of the URL to the configured Rest API class/method works, but when instantiating the object, the ActiveObjects class is not found.

The error message I see is:

io.atlassian.util.concurrent.LazyReference$InitializationException: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.acme.confluence.plugin.myPlugin.ui.QuestionnaireResource': Unsatisfied dependency expressed through constructor parameter 0;  
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.atlassian.activeobjects.external.ActiveObjects' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

The URL I am calling to test this is

http://localhost:5990/refapp/rest/myApp/1.0/questionnaires/1

The relevant part of the source code is

```
import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import javax.inject.Inject;

@Path("questionnaires")
public class QuestionnaireResource {
 @ComponentImport
 private final ActiveObjects ao;

 @Inject
 public QuestionnaireResource(ActiveObjects ao) {
  this.ao = ao;
 }

 @GET @Path("{id}")
 @Produces(MediaType.APPLICATION_JSON
 public Response get(@Context HttpServletRequest request, @PathParam("id") Integer id) {
  ...
 }
}
```

I already checked that the generated MANIFEST.MF in target/classes/META-INF contains com.atlassian.activeobjects.external in the Import-Package list.

Adding this package com.atlassian.activeobjects.external explicitly to the pom.xml Import-Package list list did not change anything.

Also, running a clean did not help. And running Confluence instead of the RefApp did not help either.

Moving the ComponentImport annotation from the instance variable to the constructor argument did not change much either, just the error message now slightly changes to contain "Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=)}".

Why is the ActiveObjects class not found? Would there be another way than injection to get access to this object?

**EDIT**: I found that the target/refpp/refapp.war file which gets created and deployed contains activeobjects-plugin-3.0.3.jar, but not activeobjects-core-3.0.3.jar. This would explain why the class is not there, but still not how I could get it to be included and instantiated correctly. I tried to include it in my pom.xml, but if the scope is not set to "provided", the build fails due to BannedDependencies. So including it in my plugin does not seem to be a viable solution.


Answers:
author: Fabian Lim
body: Hi [@Frank](/t5/user/viewprofilepage/user-id/4410127)

I suggest you post the plugin quetions in the [atlassian dev community](https://community.developer.atlassian.com/) for a faster response.

I hope you were able to figure out the issue.


Tags: active-objects

confluence-server

refapp

server