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

Create query for work item state returning NullPointException

Hi Everyone,


I follow the tutorial https://rsjazz.wordpress.com/2012/11/19/using-expressions-for-automation/ to create a work item state query expression as code snippet below:

-----------------------------------------------
IQueryableAttribute stateGroupAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectAreaHandle,IWorkItem.STATE_PROPERTY, auditableCommon, monitor);

Expression openStates = new VariableAttributeExpression(stateGroupAttribute, AttributeOperation.NOT_EQUALS, new StatusVariable(IWorkflowInfo.CLOSED_STATES));
-----------------------------------------------

It works correct to filter out work items in Unresolved state group while I test it in Jetty server. But once I deploy the plugin to WAS server then the server console shows the error below indicating that there is a NullPointException when calling VariableAttributeExpression. Anyone knows how to fix this issue? Thanks a lot.

------------------------------------------------

2018-06-20 10:31:55,670 [ccm: AsynchronousTaskRunner-2 @@ 10:31] ERROR com.ibm.team.repository                             - CRJAZ0852I An exception occurred while executing the task "Send_Reminder_Letter_taskID", contributed by component "com.ibm.team.repository".  The task will be removed from the schedule. <o:p> </o:p>

java.lang.NullPointerException <o:p> </o:p>

        at com.ibm.team.workitem.common.expression.AttributeExpression.getValueType(AttributeExpression.java:186) <o:p> </o:p>

        at com.ibm.team.workitem.common.expression.AttributeExpression.<init>(AttributeExpression.java:72) <o:p> </o:p>

        at com.ibm.team.workitem.common.expression.VariableAttributeExpression.<init>(VariableAttributeExpression.java:36) <o:p> </o:p>

        at com.delta.workitem.asynchronousTask.SendReminderLetter.queryCriteriaGeneral(SendReminderLetter.java:474) <o:p> </o:p>

        at com.delta.workitem.asynchronousTask.SendReminderLetter.distinctWhichProjectCriteria(SendReminderLetter.java:331) <o:p> </o:p>

        at com.delta.workitem.asynchronousTask.SendReminderLetter.fetchOwnerFromDelayWorkItems(SendReminderLetter.java:291) <o:p> </o:p>

        at com.delta.workitem.asynchronousTask.SendReminderLetter.dueWorkitemQuery(SendReminderLetter.java:258) <o:p> </o:p>

        at com.delta.workitem.asynchronousTask.SendReminderLetter.runTask(SendReminderLetter.java:200)

0 votes



2 answers

Permanent link

 https://rsjazz.wordpress.com/2012/11/19/using-expressions-for-automation/ uses client API. Why would that be deployed on an application server?

0 votes

Comments

Hi Ralph,


Do you mean the query expression APIs can only be used in client side? I thought it requires auditable"Common" then it would be possible to run on both serve and client side.

I also notice that this nullpointexception occurs when it tries to find the attribute for query expression through QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute. Is there any server side API can handle this? Thanks for your reply.

In my example there is client API. E.g. I needed at least IQueryClient and to get that IWorkItemClient. I am not sure if this can be achieved in the Server/Common API. I am sorry.

With respect to the Null pointer exception I would suggest to try to debug that to find out what is null and search the SDK for similar calls/examples.

Also, check the include statement for package names that include .client. This is not going to be available in a WAS server. but could be available in Jetty through the client SDK.

Hi Ralph, please find my comment on below Answer section because of the character limit of Comment section. 


Permanent link

 Hi Ralph,

I use following APIs to achieve the same purpose of what you mentioned:
----------------------------------------------------------------
public IQueryCommon fqueryCommon;
fqueryCommon = ((IQueryCommon)getService(IQueryServer.class)); 
IQueryResult<IResolvedResult<IWorkItem>> queryResult = fqueryCommon.getResolvedExpressionResults(projectAreaHandle, filterTerm, IWorkItem.FULL_PROFILE);
----------------------------------------------------------------
I look into findAttribute method during debugging, find out that:
----------------------------------------------------------------
checkCache(projectArea, auditableCommon, monitor);
Entry entry= fCache.get(projectArea.getItemId());
IQueryableAttribute cached= entry.attributeMap.get(attributeIdentifier);
----------------------------------------------------------------
The attributeIdentifier inside attributeMap doesn't contain some basic builtin attributes such as Project Area, Work Item Type and Due Date...so whenever I utilize findAttribute method to retrieve attributes like IWorkItem.PROJECT_AREA_PROPERTY, IWorkItem.DUE_DATE_PROPERTY, it will return Null. Totally no idea why this happens....
 

0 votes

Comments

Sorry, but I haven't used these API calls. I find this suspicious:

IQueryableAttribute cached= entry.attributeMap.get(attributeIdentifier); 

This is no API I have used so far and if I look at IQueryableAttribute this is usually retrieved using a factory if I look into the SDK.

You could try to get the unresolved results. You should also consider to use the access permission aware API.

Sorry I can not help.

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

Question asked: Jun 19 '18, 11:05 p.m.

Question was seen: 1,515 times

Last updated: Jun 22 '18, 5:10 a.m.

Confirmation Cancel Confirm