I am very new to plugin development , getting null pointer exception when i am trying to create issue type using plugin
following is my servelet code
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.atlassian.jira.config.IssueTypeManager;
import com.atlassian.jira.issue.issuetype.IssueType;
public class CreateIssueTypeManagerImpl extends HttpServlet {
private IssueTypeManager issueTypeManager;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType(“text/plain”);
PrintWriter out = resp.getWriter();
out.println(“Creating Issue…”);
out.flush();
IssueType customIssue = issueTypeManager.createIssueType(“TestCase”,
“Test case issue type”, (long) 10000);
if (customIssue != null) {
out.println("Updating " + customIssue.getId());
}
out.println(“issue is not created”);
}
}
plguin.xml entry
/issueManager
error log
[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer] at com.testcase.plugin.impl.CreateIssueTypeManagerImpl.doGet(CreateIssueTypeManagerImpl.java:26)
Hi @mailtomano. I’ll need some more information in order to help you. Can you provide more of the stacktrace that you are getting, including some lines referring to code in JIRA itself? Which version of JIRA are you using? Are you very sure that there is an avatar with ID 10000?
By the way, the </> item on the editor toolbar in this developer forum will format your code snippets to make them more readable, like this:
import java.io.IOException;
...
public class CreateIssueTypeManagerImpl extends HttpServlet {
private IssueTypeManager issueTypeManager;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/plain");
PrintWriter out = resp.getWriter();
out.println("Creating Issue...");
...
}
}
Thanks David for the replay
i am able to resolve this issue by adding
issueTypeSchemeManager = ComponentAccessor.getIssueTypeSchemeManager();
in init method
I used 10000 randomly but image is not getting displayed
could you please help me to know, how to get valid avatar id or list of valid ids thanks
following simple steps will get avatar ids
go to issue type select edit option and try to change the image
select the image and right click and select the option copy image address
and you get url like this
http://din20000106:2990/jira/secure/viewavatar?size=xsmall&avatarId=10315&avatarType=issuetype
And i used that avatar id and it worked well