NullPointerException while creating workitem programmatically using server side plugin
Hi,
I am creating workitem automatically using server side plugin.
I am taking values from enumeration list and using that value creating workitem using method createWorkItem2();
I am using following code for read enum value and create and update WI:
IAttribute workproduct = workItemCommon.findAttribute(projectArea, "workproductsn", monitor);
IEnumeration enumeration = workItemCommon.resolveEnumeration(workproduct, monitor);
List enumIdList = (List)sourceworkItem.getValue(workproduct);
for (int k = 0; k < enumIdList.size(); k++)
{
int newcount = 0;
Identifier literalId = (Identifier)enumIdList.get(k);
ILiteral literal = enumeration.findEnumerationLiteral(literalId);
String Workpdt = literal.getName();
String reqphases="Planning";
String req = reqphases;
if (req.equalsIgnoreCase(Workpdt))
{
WorkItemType workpdtType = workItemCommon.findWorkItemType(projectArea, child, monitor);
IWorkItem workpdtWI = workItemServer.createWorkItem2(workpdtType);
IAttribute wpSummary = workItemCommon.findAttribute(projectArea, "summary", monitor);
Object wpSummaryVal = Workpdt;
workpdtWI.setValue(wpSummary, wpSummaryVal);
newcount++;
int workpdtWIId = workpdtWI.getId();
IWorkItem workpdtWIForUpdate = workItemServer.findWorkItemById(workpdtWIId, IWorkItem.FULL_PROFILE, monitor);
if (workpdtWIForUpdate == null)
{
workpdtWIForUpdate = workpdtWI;
}
IStatus pdtstatus = workItemServer.saveWorkItem2(workpdtWIForUpdate, null, null);
if (!pdtstatus.isOK())
{
IReportInfo problem = collector.createExceptionInfo(
"Work item is of type: " +
sourceworkItem.getWorkItemType(),
new Exception("Error in Saving the Child (Work Phase) WorkItem"));
collector.addInfo(problem);
}
Please,provide some help.
Thanks in advance.
|
One answer
Ralph Schoon (63.4k●3●36●46)
| answered Jun 26 '15, 4:08 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I have always found this easy to detect while debugging with Jetty as described in https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ and the referred Extensions Workshop. If you don't do that today, because you want to save the two hours needed to set this up, I would strongly recommend to change your mind. It would also be a great idea to share the top of the stack trace to be able to tell where the nullpointer happens.
In general my experience with Nullpointer Exceptions in my code is that it was usually my fault. |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.