It's all about the answers!

Ask a question

Create query for work item state returning NullPointException


Kenery Wang (6411727) | asked Jun 19 '18, 11:05 p.m.

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)

2 answers



permanent link
Ralph Schoon (63.1k33645) | answered Jun 20 '18, 1:57 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


Comments
Kenery Wang commented Jun 21 '18, 5:26 a.m. | edited Jun 21 '18, 5:34 a.m.

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.


Ralph Schoon commented Jun 21 '18, 5:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Ralph Schoon commented Jun 21 '18, 5:57 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Kenery Wang commented Jun 22 '18, 3:39 a.m.

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


permanent link
Kenery Wang (6411727) | answered Jun 22 '18, 3:38 a.m.

 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....
 


Comments
Ralph Schoon commented Jun 22 '18, 5:10 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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 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.