Not able to create custom issue type from plugin

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

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

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

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

/Christoffer

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.

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

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
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

133 views 0 3
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