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

NullPointerException when change state of workitem

Hi All,

When my plugin change the state of a existing workitem, it throws this exception.

but the error log below does not tell me which line of my code cause the error.
Any reply would be appreciate.

Thanks

java.lang.NullPointerException
at com.ibm.team.apt.internal.client.planchecker.RequiredAttributeCheck$RequiredPropertiesCache.get(RequiredAttributeCheck.java:189)
at com.ibm.team.apt.internal.client.planchecker.RequiredAttributeCheck.run(RequiredAttributeCheck.java:124)
at com.ibm.team.apt.internal.client.planchecker.RequiredAttributeCheck.runDeltaCheck(RequiredAttributeCheck.java:75)
at com.ibm.team.apt.internal.client.planchecker.PlanCheckEngine$DeltaCheckRun.execute(PlanCheckEngine.java:332)
at com.ibm.team.apt.internal.client.planchecker.PlanCheckEngine$PlanDetectionQueue$1.run(PlanCheckEngine.java:265)
at com.ibm.team.apt.internal.client.ResolvedPlan.runConnected(ResolvedPlan.java:466)
at com.ibm.team.apt.internal.client.planchecker.PlanCheckEngine$PlanDetectionQueue.run(PlanCheckEngine.java:263)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

0 votes



6 answers

Permanent link
Hi
How do you change the state of the work item? The only supported way is to set the action id to the working copy. Setting the state directly is not supported.

Could you paste the code snippet that does not work?

Regards

Marcel
Jazz Work Item team

0 votes


Permanent link
Hi Marcel,

It's really nice to see your reply here. I create a popup menu for the workitem, and all the possible state is a menu item in this menu. And each menu item has a ChangeWorkItemStateAction.

ChangeWorkItemStateAction action= new ChangeWorkItemStateAction(workflowInfo.getActionName(actionId), workItem, actionId,this);



IWorkItem workItem = ((CommentNode)second).getCommentObj().getWorkItem();

if (workItem != null) {
manager.add(new OpenSourceFile(Message.VIEWACTION_OPENSOURCE,workItem,getSite().getPart(),getSite().getWorkbenchWindow().getActivePage()));
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
ITeamRepository repository= (ITeamRepository) workItem.getOrigin();
IWorkItemClient client= (IWorkItemClient) repository.getClientLibrary(IWorkItemClient.class);
IWorkflowInfo workflowInfo = null;
try {
workflowInfo = client.findWorkflowInfo(workItem, null);
} catch (TeamRepositoryException e) {
e.printStackTrace();
return;
}
Identifier<IState> state= workItem.getState2();
if (state != null) {
Identifier<IWorkflowAction>[] actionIds= workflowInfo.getActionIds(state);
if (actionIds.length > 0) {
for (int i= 0; i < actionIds.length; i++) {
Identifier<IWorkflowAction> actionId= actionIds[i];
ChangeWorkItemStateAction action= new ChangeWorkItemStateAction(workflowInfo.getActionName(actionId), workItem, actionId,this);
URL url= workflowInfo.getActionIconName(actionId);
if (url != null) {
ImageDescriptor descriptor= WorkItemUI.getImageDescriptor(url);
if (descriptor != null)
action.setImageDescriptor(descriptor);
}
if(!action.getText().equals("Triage"))
manager.add(action);
}
}
}






private static class ChangeWorkItemStateAction extends Action {

private IWorkItem fWorkItem;
private Identifier<IWorkflowAction> fActionId;
private EasyInspectAllView view;
public ChangeWorkItemStateAction(String name, IWorkItem workItem, Identifier<IWorkflowAction> actionId,EasyInspectAllView view) {
super(name);
fWorkItem= workItem;
fActionId= actionId;
this.view=view;
}

@Override
public void run() {
if (fWorkItem == null)
return;
WorkItemOperation operation= new ChangeWorkItemStateOperation("Changing state", fActionId);
try {
operation.run(fWorkItem, null);
view.refreshInspections();
view.getCommentViewer().expandToLevel(2);
} catch (TeamRepositoryException e) {
e.printStackTrace();
}
}
}


Thanks!

0 votes


Permanent link
Hi
This looks basically OK to me. I have opened defect 98932: NPE in RequiredAttributeCheck changing state using ChangeWorkItemStateOperation (https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/98932) to track the issue.
Can you please comment in that work item which version of RTC you are using.

Regards

Marcel
Jazz Work Item team

0 votes


Permanent link
Hi Marcel,
I can't open this page, the page is blank with only "Loading" in the center. So I am sorry maybe I can't give my comment on that page.
There is something else about this problem, when i run/debug my plugin code, it works just fine. When I depoly it into plugin, and use it in the real Jazz environment, this problem start to appear.
Regards~

Yaoben

Hi
This looks basically OK to me. I have opened defect 98932: NPE in RequiredAttributeCheck changing state using ChangeWorkItemStateOperation (https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/98932) to track the issue.
Can you please comment in that work item which version of RTC you are using.

Regards

Marcel
Jazz Work Item team

0 votes


Permanent link
I have select my version and os, and give comment to it. So is there anything I can do to help?

Hi
This looks basically OK to me. I have opened defect 98932: NPE in RequiredAttributeCheck changing state using ChangeWorkItemStateOperation (https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/98932) to track the issue.
Can you please comment in that work item which version of RTC you are using.

Regards

Marcel
Jazz Work Item team

0 votes


Permanent link
The below metioned code for changing workitem state is not working for me.

private static class ChangeWorkItemStateAction extends Action {

private IWorkItem fWorkItem;
private Identifier<IWorkflowAction> fActionId;
private EasyInspectAllView view;
public ChangeWorkItemStateAction(String name, IWorkItem workItem, Identifier<IWorkflowAction> actionId,EasyInspectAllView view) {
super(name);
fWorkItem= workItem;
fActionId= actionId;
this.view=view;
}

@Override
public void run() {
if (fWorkItem == null)
return;
WorkItemOperation operation= new ChangeWorkItemStateOperation("Changing state", fActionId);
try {
operation.run(fWorkItem, null);
view.refreshInspections();
view.getCommentViewer().expandToLevel(2);
} catch (TeamRepositoryException e) {
e.printStackTrace();
}
}
}

In the above code 'ChangeWorkItemStateOperation' method seems erroneuos. Please help me to fix it.

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,926

Question asked: Nov 04 '09, 4:28 a.m.

Question was seen: 6,631 times

Last updated: Nov 04 '09, 4:28 a.m.

Confirmation Cancel Confirm