Does anyone know how to implement the SprintManager?

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

This widget could not be displayed.

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

This widget could not be displayed.

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

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().

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.

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 Community Champion Sep 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?

I have the same error sad

I use it:

final PluginAccessor pluginAccessor = ComponentManager.getComponent(PluginAccessor.class);
Plugin plugin = pluginAccessor.getEnabledPlugin("com.pyxis.greenhopper.jira");

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.*;
This widget could not be displayed.

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

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

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.

@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

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

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

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

176 views 18 7
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