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

0 vote
Timothy Chin Community Champion Jun 25, 2014

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

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.

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.

0 vote

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.

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
		);
	}
}

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,316 views 14 20
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot