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

Retrieve history of work item states

I have the following code to begin retrieving the history of a work item using the plain java client.


WorkItemClient workItemClient= (WorkItemClient) repository.getClientLibrary(WorkItemClient.class);
IWorkItemClient iWiClient = (IWorkItemClient) repository.getClientLibrary(IWorkItemClient.class);
IWorkItem workItem = iWiClient.findWorkItemById(defectId, IWorkItem.FULL_PROFILE, monitor);

List<ChangeLogDTO> log = workItemClient.computeWorkItemHistory(workItem, monitor);


The issue I'm running into is that the last line of the snippet is throwing a null pointer exception. Not exactly sure why I'm getting that and hoping someone here would have some insight or if there's a better way.

Steve

0 votes



3 answers

Permanent link
You get a NullPointerException because you cannot get an instance of the WorkItemClient.class with:
WorkItemClient  workItemClientInternal = (WorkItemClient) repository.getClientLibrary(WorkItemClient.class);
You have to use the constructor method:
WorkItemClient workItemClientInternal = new WorkItemClient((IClientLibraryContext) repo);
and where repo is your ITeamRepository current instance.
Cheers.

0 votes


Permanent link
what is 'defectId'?

the findWorkItemById is failing..

Sam


'defectId' is an int with a value of 7976, which is a valid work item ID in our database.

findWorkItemById is not failing because I can get the various values of the work item that are available with the workItem object, such as description, summary, etc.

0 votes


Permanent link
what is 'defectId'?

the findWorkItemById is failing..

Sam

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

Question asked: Feb 14 '12, 4:55 p.m.

Question was seen: 5,130 times

Last updated: Jun 18 '12, 5:39 a.m.

Confirmation Cancel Confirm