Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Getting Error Injecting ActiveObjects

Edited

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.

1 answer

0 votes
Fabian Lim Community Leader Dec 24, 2021

Hi @Frank

I suggest you post the plugin quetions in the atlassian dev community for a faster response.

I hope you were able to figure out the issue.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

41,777 views 29 131
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you