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

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
		);
	}
}
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
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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

696 views 6 13
Read article

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