Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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.

0 votes



One answer

Permanent link
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.

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,951

Question asked: Jun 26 '15, 3:50 a.m.

Question was seen: 2,537 times

Last updated: Jun 26 '15, 4:08 a.m.

Confirmation Cancel Confirm