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
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
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);
Thanks!
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!
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
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
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
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
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
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.
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.