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

Unsatisfied depedency when using ActiveObjects Edited

Hi.

I try add ActiveObjects storage service to plugin but get on runtime

Error autowiring Action 'com.avvd.jira.plugin.defaulter.WebWork'.
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'com.avvd.jira.plugin.defaulter.WebWork':
Unsatisfied dependency expressed through constructor argument with index 0
of type [com.atlassian.activeobjects.external.ActiveObjects]:
No qualifying bean of type [com.atlassian.activeobjects.external.ActiveObjects]
found for dependency: expected at least 1 bean which qualifies as autowire candidate
for this dependency. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=)};
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.activeobjects.external.ActiveObjects]
found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=)}

 Plugin access point is

@Scanned
public class WebWork extends JiraWebActionSupport {

private ConfigurationStorageService configurationStorageService;

@Inject
public WebWork(@ComponentImport ActiveObjects ao)
{
this.configurationStorageService = new ConfigurationStorageService(ao);
}
@Override
public String doExecute()
{

Storage service 
 

public class ConfigurationStorageService implements ConfigurationStorage {

private ActiveObjects ao;
public ConfigurationStorageService(ActiveObjects ao){this.ao = ao;}

pom.xml

<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.activeobjects</groupId>
<artifactId>activeobjects-plugin</artifactId>
<version>${ao.version}</version>
</pluginArtifact>
</pluginArtifacts>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<!-- Add package to export here -->
<Export-Package>
com.avvd.jira.plugin.defaulter
</Export-Package>
<!-- Add package import here -->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
*;version="0";resolution:=optional
</Import-Package>
<Spring-Context>*</Spring-Context>
</instructions>
</configuration>
</plugin>

<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>6</source>
<target>6</target>
</configuration>
</plugin>
</plugins>
</build>




Also don't miss create entity in atlassian-plugin.xml
What i miss?
Thank for advice.


 

4 answers

0 votes
DPK J Community Leader Aug 28, 2019

Have you got below in you atlassian-plugin.xml file?

<component-import key="ao" name="Active Objects service" interface="com.atlassian.activeobjects.external.ActiveObjects">  <description>Component to access Active Objects functionality from the plugin</description></component-import>

Not component-import. Just 

<ao key="Defaulter helper table">
<entity>com.avvd.jira.plugin.defaulter.storage.ConfigurationEntity</entity>
</ao>

 This is spring-scanner 

DPK J Community Leader Aug 28, 2019

Please add above and try.

Add component-import and remove all annotations 
clean->package 
cause 0 beans of AO on runtime

it's fun and expectdly but when declairing service 

@Component
public class ConfigurationStorageService implements ConfigurationStorage {

private ActiveObjects ao;

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

cause 2 AO beans

0 votes

Hi,

I am working with AO in some of my projects...

But I didn't understand what you did here, what do you mean by "Plugin access point"?

You should use AO to create a table inside your Jira database.

So you need first to create an interface which represent the table and it's columns like:

import net.java.ao.Accessor;
import net.java.ao.Entity;
import net.java.ao.Preload;
import net.java.ao.schema.Table;
import java.util.Date;

@Table("Table_Name")
@Preload
public interface MyInterface extends Entity {   
@Accessor("Column_Name_1")
  public String getXXX();
    public void setXXX(String XXX);   

@Accessor("Column_Name_2")
    public Date getYYY();
    public void setYYY(Date YYY);
}

Than create the service interface like:

import java.util.Date;
import java.util.List;

@Transactional
public interface MyInterfaceService {   

MyInterface add(String XXX, Date YYY); 

/*other methods like update, delete and so on...    */

List<MyInterface> all();
}

Eventually your service is like:

import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import net.java.ao.Query;

@Scanned
@Named
public class MyInterfaceServiceImpl implements MyInterfaceService {   
@ComponentImport
    private final ActiveObjects ao;   

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

@Override
    public MyInterface add(String XXX, Date YYY) {
        final MyInterface record = ao.create(MyInterface.class);
        record.setXXX(XXX);
        record.setYYY(YYY);       
record.save();       
return record;
    }   

@Override
    any other method you created   

@Override
    public List<MyInterface> all() {
        return newArrayList(ao.find(MyInterface.class));
    }
}

everything you want to do with you table, any method regarding it should be done in the service class.

Than if you want to use it in other classes you should do like:

@Component
public class Program {
    private static final Logger log = LoggerFactory.getLogger(Program.class);   
private final MyInterfaceServiceImpl myInterfaceServiceImpl    

@Autowired
public Program(MyInterfaceServiceImpl myInterfaceServiceImpl) {
        this.myInterfaceServiceImpl = myInterfaceServiceImpl;
    }   

public void main() {
   myInterfaceServiceImpl.add(XXX, YYY)
  }
}

in plugin.xml

<ao key="ao-module">
    <description>The AO module for this plugin.</description>
    <entity>${atlassian.plugin.key}.active_objects.MyInterface</entity>
</ao>

If you do everything as I said I promise you it will work

Still no changes. 
Can you show your pom.xml?

Nir Haimov Community Leader Aug 29, 2019

if there are no errors in your ide, then your probably fine...

Try to clean your project and re-run again

mvn-clean
atlas-run

I am creating packages and run them on test instance. Yes. I doing this.

I download latest SDK(i have 6.x version) Simplify pom.xml and will try to check it up now.

 

....

but no changes

Can you give me your pom.xml file. I think that i declare maven plugin in the wrong way.

This is repository. In case i will resolve this issue, i place solution there.

 

https://gitlab.com/svchost1101/defaulter

I found that IDEA highlights 

<atlassian-scanner:scan-indexes/>

With warning: This custom Spring bean has not yet been parsed.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

225 views 2 5
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