It's all about the answers!

Ask a question

NullPointerException when change state of workitem


yaoben lu (5681) | asked Nov 04 '09, 4:28 a.m.
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)

6 answers



permanent link
sanjay chaniya (6) | answered Oct 25 '10, 7:19 a.m.
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.

permanent link
yaoben lu (5681) | answered Nov 09 '09, 3:38 a.m.
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

permanent link
yaoben lu (5681) | answered Nov 09 '09, 3:24 a.m.
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

permanent link
Marcel Bihr, Jazz Work Item team (1.4k) | answered Nov 09 '09, 2:55 a.m.
JAZZ DEVELOPER
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

permanent link
yaoben lu (5681) | answered Nov 08 '09, 10:46 p.m.
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!

permanent link
Marcel Bihr, Jazz Work Item team (1.4k) | answered Nov 04 '09, 6:22 a.m.
JAZZ DEVELOPER
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

Your answer


Register or to post your answer.