Null Pointer Exception - CCM logs (ccm.log)
we are getting Null pointer exception entries in ccm.logs, whenever user is trying to create new workitem/refresh work item.
java.lang.NullPointerException
at com.ibm.team.workitem.service.internal.rest.WorkItemRestService.collectAdvisorConfigurations(WorkItemRestService.java:2318)
at com.ibm.team.workitem.service.internal.rest.WorkItemRestService.getDynamicAttributesPropertiesConfiguration(WorkItemRestService.java:2298)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
We have server side plugin developed which implements ICondition. Plugin doesn't have extension point (Operation ID), so it is not actually the standard Server side plugin way. It is just implementing ICondition.
This deals with attributes readonly/mandatory/writable behaviour.Plugin at the end returns only true or false.
Observations
Without installing this plugin - no entries of Null pointer exception in the ccm logs.
With plugin - Null Pointer exception entries in the log.
So investigated if exception happening from plugin class - but it is happening other IBM class ( collectAdvisorConfigurations(WorkItemRestService.java:2318)) over which we don't have control to catch this exception.
Tested catching the exception inside plugin - nothing was caught, so it means null pointer exception not happening from invocation of IBM classes from this plugin.
If any body has idea about such scenarios please share/comment.
2 answers
If you have an ICondition extension deployed, the condition is used in and advisor e.g.
- Read Only for Condition
- Required for Condition
as you explain.
Other than in a normal advisor that only runs when someone presses the safe button, the advisors above (and the *** for Type and State) are called in the UI thread when opening a work item. This also happens in the Web UI.
You can connect to the server and debug what is happening.
I don't know what leads to that situation either, but I would check the configuration and potentially try to debug the issue on the server or on a Jetty debug server.
Note that the read only and required
This is not an answer, but a comment to the answer from Ralph.
The null value comes from com.ibm.team.workitem.service.internal.rest.DTOConversionService.convertValueProvider(IConfiguration)
which returns null if providerClass is null. And the providerClass is null because it is taken from
com.ibm.team.workitem.common.internal.attributeValueProviders.AbstractConfiguration.getScriptClass()
which only looks for the <script> entries in the configuration which our template doesn't have.
So, this is a template configuration issue. Looks like there should be
<script class="someclass"></script>
entries for every condition in the specification.xml.
Adding such entries for all Required and Read-Only Conditions makes the NPE disappear.
But then there is a side-effect:
The Web-UI tries to execute the script in order to show the mandatory mark (* asterisk) for all the elements.
With an empty script the mandatory mark in WebUI just disappears. Without the <script/> elements the mandatory marks are shown properly despite the NPE. With the <script/> elements, the mandatory fields are not marked.
One obvious workaround would be to implement the 'matches' in the JavaScript which would do exactly the same as the Java 'matches' in the server-side extension. But we would really like to avoid code duplication. Are there any better solutions?