Jira Service and ActiveObjects problem

Hello,

I create a service and I need to use an activeObject to add in my database some informations.

My Service :

public class TestService extends AbstractService {

	public JiraHome jiraHome;
	public ActiveObjects ao;

	public TestService(JiraHome jiraHome,ActiveObjects ao) {
		this.jiraHome = jiraHome;
		this.ao = ao;
	}

	@Override
	public void run() {
		AddDataFromCsv adfc = new AddDataFromCsv(jiraHome, ao);
		adfc.addBD();

	}

	@Override
	public ObjectConfiguration getObjectConfiguration() throws ObjectConfigurationException {
		return getObjectConfiguration("TESTSERVICE",
				"services/com/atlassian/tutorial/helloworld/testservice.xml",
				null);
	}

}
The class AddDataFromCsv works fine.

When itry to add my service in jira i have an error and i don't understand what it means :

com.atlassian.tutorial.helloworld.TestService has unsatisfied dependency 'interface com.atlassian.activeobjects.external.ActiveObjects' for constructor 'public com.atlassian.tutorial.helloworld.TestService(com.atlassian.jira.config.util.JiraHome,com.atlassian.activeobjects.external.ActiveObjects)' from org.picocontainer.DefaultPicoContainer@20d535de:1<[Immutable]:com.atlassian.jira.component.CachingMutablePicoContainer@56c4e51e.


Thanks.

5 answers

This widget could not be displayed.

I've just run into the same problem. After few attempts i got solution.

Import ao in atlassian-plugin.xml

<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>

 

Use setter to init ao within the service.

package com.togethernetworks.plugins.services.kpi;
import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.configurable.ObjectConfiguration;
import com.atlassian.configurable.ObjectConfigurationException;
import com.atlassian.jira.service.AbstractService;
import com.opensymphony.module.propertyset.PropertySet;
import java.util.Date;

public class KpiService extends AbstractService
{
	private final static String SERVICE_ID = "someservice";
	private final static String SERVICE_CONF = "services/kpi/kpiservice.xml";
	private ActiveObjects activeObjects;
	private String parseDate;
	
	public void setActiveObjects(ActiveObjects activeObjects)
	{
		this.activeObjects = activeObjects;
	}
	
	@Override
	public void run()
	{
		System.out.println("Running service!!" + this.parseDate);
	}
	
	public void init(PropertySet props) throws ObjectConfigurationException
	{
		super.init(props);
		
		if (this.hasProperty("test")) {
			
			this.parseDate = this.getProperty("test");
			
		}
	}
	@Override
	public ObjectConfiguration getObjectConfiguration() throws ObjectConfigurationException
	{
		return this.getObjectConfiguration(
			KpiService.SERVICE_ID,
			KpiService.SERVICE_CONF,
			null
		);
	}
}
This widget could not be displayed.
Timothy Chin Community Champion Jun 25, 2014

Not a solution but ActiveObjects and services do not mix well.

This widget could not be displayed.

Thanks for you answer but what can you propose to me for update my database every hour ? I thought services were the best solution to do this.

This widget could not be displayed.

Thanks for you answer but what can you propose to me for update my database every hour ? I thought services are the best solution to do this.

This widget could not be displayed.
Daniel Wester Community Champion Jun 25, 2014

Create your own service and do all of the active object interaction in there. Then import that service into your Service class. Or use SAL's Job functionality.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

115 views 2 0
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you