Not able to create custom issue type from plugin

maki maki February 18, 2014
I am trying to create custom issue type from my plugin, but have been unsuccessful so far. I have followed example outlined here, but when I do -atlas-run I get error that IssueTypeManager is not instantiable. I am completly blockedon my plugin development due to this as this is the first thing that needs to happen by the design, so your help is very much appreciated. If you need any more info than this please let me know. The code is exactly like this:

package com.myjiraplugins;
import com.atlassian.jira.config.IssueTypeManager;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.sal.api.ApplicationProperties;

public class MyPluginComponentImpl implements MyPluginComponent {
private final ApplicationProperties applicationProperties;

public MyPluginComponentImpl(ApplicationProperties applicationProperties) { this.applicationProperties = applicationProperties;

IssueTypeManager itm = (IssueTypeManager) JiraUtils.loadComponent(IssueTypeManager.class); itm.createIssueType("mytype", "custom issue type", "/images/icons/issuetypes/genericissue.png");
}
public String getName() { if(null != applicationProperties) {

return "myComponent:" + applicationProperties.getDisplayName();
}
return "myComponent";
}
}

3 answers

0 votes
Christoffer Karlsson February 20, 2014

Hi,

I don't think you should try to initiate the ComponentAccessor. You can use it directly like this:

IssueTypeManager itm = ComponentAccessor.getComponent(IssueTypeManager.class);

But prefered way of doing it is to simply specify in the constructor that you will need this object:

public MyPluginComponentImpl(ApplicationProperties applicationProperties, IssueTypeManager itm) { this.applicationProperties = applicationProperties;

Feel free to mark any of my answers as best answers to mark this question as solved if it helped you with your problems :)

BR

Christoffer

0 votes
Christoffer Karlsson February 18, 2014

If we are talking about the same things, it's also explained here:

https://developer.atlassian.com/pages/viewpage.action?pageId=4227139

/Christoffer

maki maki February 20, 2014

Thank you Christoffer. It helped me, I was able to create custom type. Though, I was getting error that ComponentAccessor is not initialized, even after Ihave made object of it and assigned null value to it. So, I have disabled unit test and everything was fine then. Thanks again.

0 votes
Christoffer Karlsson February 18, 2014

Hi,

Can you try to use for example:

ComponentAccessor.getComponent(IssueTypeManager.class)

or

ComponentAccessor.getComponentOfType(IssueTypeManager.class)

instead of using the Jirautils to load the class?

BR
Christoffer

Suggest an answer

Log in or Sign up to answer