Does anyone know how to implement the SprintManager?

Paul Bailey July 23, 2014

As seen in the method below, sprintManger.getAllSprints() is causing a null pointer exception . This makes me think that I am not implementing the SprintManager correclty.

// Here is the method where I am experiencing the problem

ServiceOutcome<Collection<Sprint>> getSprints(){

SprintManager sprintManager = ComponentAccessor.getComponent(SprintManagerImpl.class);

return sprintManager.getAllSprints();

}

I have also tried implementing the SprintManager by the following way:

SprintManager sprintManager = new SprintManagerImpl();

But it also causes a null pointer exception.

Does anyone know the right way to do this?

Thanks!

3 answers

1 accepted

0 votes
Answer accepted
Paul Bailey September 19, 2014

Use REST calls to access sprint info. This is much easier then trying to use the SprintManager class.

5 votes
Marten Kreienbrock
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 29, 2014

Unfortunatly, it is a little more tricky to get this class. I managed it using this code:

private SprintManager getSprintManager() throws InvalidSyntaxException {
		
	ApplicationContext appCtx = (ApplicationContext) getGreenHopperAppCtx();
        if ( appCtx !=null ) {
	    	return (SprintManager) appCtx.getBean( "sprintManagerImpl" );
	    }
	    return null;
	}
	
private Object getGreenHopperAppCtx() throws InvalidSyntaxException {
	OsgiContainerManager osgi = ComponentAccessor.getComponentOfType(OsgiContainerManager.class);
	    if ( osgi==null ) {
			 java.lang.System.out.println("OSGI Not Found");
			 return null;
	    }

	    Bundle[] bundles = osgi.getBundles();

	    
	    for(int i=0;i&lt;bundles.length;i++) {
	    	Bundle bundle = bundles[i];

	        if ( "com.pyxis.greenhopper.jira".equals( bundle.getSymbolicName() ) ) {

	        	BundleContext bctx = bundle.getBundleContext();
	        	ServiceReference[] refs = bctx.getAllServiceReferences(null,null);
	        	if ( refs!=null ) {
	        		for(int j=0; j&lt;refs.length;j++) {
	        			Object prop = refs[j].getProperty("org.springframework.context.service.name");
	        			if ( "com.pyxis.greenhopper.jira".equals(prop) ) {
	        				return bctx.getService( refs[j] );
	        			}
	        			
	        		}
	        	}
	        }
	    }
	    return null;
	}

Paul Bailey July 29, 2014

Thanks, that is getting me closer to a solution. I am having an issue in the line

return(SprintManager) appCtx.getBean( "sprintManagerImpl");

My IDE seems to think that the ApplicationContext is an import from

electric.glue.context.ApplicationContext;

Is that the import that you are using? My appCtx does not seem to have a method called getBean().

Marten Kreienbrock
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 30, 2014

I currently can't tell you what class it was exactly, but I'm sure it was not from the electric.glue package. If I remember correctly, the class should be from org.springframework.

Dan Mihalache August 12, 2015

It's org.springframework.context (http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/ApplicationContext.html) To have it, you need to include in your pom.xml: <dependency> <groupId>org.springframework.osgi</groupId> <artifactId>spring-osgi-core</artifactId> <version>1.1.3</version> <scope>provided</scope> </dependency>

Aleksandr Zuevich
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 20, 2016

If my plugin is installed before greenhopper (Agile) is installed, I've got java.lang.ClassNotFoundException: com.atlassian.greenhopper.service.sprint.SprintManager. How to fix it?

Alexander Pampushko March 5, 2017

I have the same error sad

I use it:

final PluginAccessor pluginAccessor = ComponentManager.getComponent(PluginAccessor.class);
Plugin plugin = pluginAccessor.getEnabledPlugin("com.pyxis.greenhopper.jira");
Like Dmitry Sokolov likes this
jacob delddd July 9, 2018

all the dependencies:

http://www.java2s.com/Code/Jar/a/Downloadatlassianpluginsosgi260jar.htm 

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.framework</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.sonatype.tycho</groupId>
<artifactId>maven-osgi-packaging-plugin</artifactId>
<version>0.11.1</version>
</dependency>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-components</artifactId>
<version>7.1.0-QR20151201104527</version>
</dependency>
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-bridge</artifactId>
<version>5.0.0-6892e16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
//applicationcontext
import org.springframework.context.*; //kan kleiner
//invalidsyntax
import org.osgi.framework.InvalidSyntaxException;
//OsgiContainerManager
import com.atlassian.plugin.osgi.container.OsgiContainerManager;
import com.atlassian.plugin.osgi.container.OsgiContainerException;

//ComponentAccessor
import com.atlassian.jira.component.ComponentAccessor;
//getSymbolicName
import org.osgi.framework.*;
0 votes
Skymetrix IT July 20, 2017

For Jira v7 look at https://community.atlassian.com/t5/Answers-Developer-Questions/Change-sprint-value-by-groovy-script/qaq-p/522895#M60555

 (Took me a while to find it, and this thread came up a thousand times on google - has the right keywords in it. That's why I'm commenting on such an old entry.)

Sevak Asadorian November 13, 2017

@Skymetrix IT Hi, this is using groovy though. Any idea on how to do this using pure java api?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 13, 2017

The groovy is not far off, in fact it's using java calls already.

For the script that was quoted in the link, all you need to do is replace the "def" uses with the java variable object types for the return values (e.g. if you had "def i = 3", convert it to "int i = 3") and add ; to the end of the lines.

Sevak Asadorian November 13, 2017

10-4.

Ill try that.

Sevak Asadorian November 14, 2017

@Nic Brough -Adaptavist-

Is there a way to "extend" the built in 'Burndown Chart' that is provided with our current Jira instance?

If so how?

I have been searching through the source and I am unable to find it.

Please advise.

 

bc.png

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 14, 2017

Not directly, but you could download the code and hack it (if you have a commercial licence)

Sevak Asadorian November 15, 2017

@Nic Brough -Adaptavist-

Is there an example that shows the SprintManager usage for Jira 7?

Been searching for some time.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events