Error invoking validator - com.ibm.team.workitem.valueproviders.VALIDATOR._WPftQIBqEeWJZe1YTWhytQ
I am getting below exception messages in ccm logs and this makes the server performance very slow.
2016-03-01 14:26:30,318 [WebContainer : 3 @@ 14:26 soalagappan <com.ibm.team.workitem.newWorkItem/Save@e6e831a7-8797-4719-89f0-064f2597ace2> /ccm/service/com.ibm.team.workitem.common.internal.rest.IWorkItemRestService/workItem2] ERROR com.ibm.team.workitem.common - Error invoking validator com.ibm.team.workitem.valueproviders.VALIDATOR._WPftQIBqEeWJZe1YTWhytQ com.ibm.team.repository.common.TeamRepositoryException: Unexpected exception type at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.handleException(ScriptAttributeValueProvider.java:281) at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.validate(ScriptAttributeValueProvider.java:149)
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot call method "getFullYear" of null ({"Bundle-SymbolicName":"org.dojotoolkit.dojo", "path":"\\resources", "name":"date.js"}#224)
Has anyone experienced this issue?
5 answers
I already found the java script which causing the problem. This script used to validate the past date selection in a time stamp attribute.
Script below:
/*******************************************************************************
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation 2011. All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule
* Contract with IBM Corp.
*******************************************************************************/
dojo.provide("test");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("com.ibm.team.workitem.api.common.Severity");
dojo.require("com.ibm.team.workitem.api.common.Status");
dojo.require("dojo.date");
dojo.require("dojo.date.stamp");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var Severity= com.ibm.team.workitem.api.common.Severity;
var Status= com.ibm.team.workitem.api.common.Status;
dojo.declare("test", null, {
validate: function(attribute, workItem, configuration) {
var defectstate = workItem.getLabel(WorkItemAttributes.STATE);
var targetfixdate = dojo.date.stamp.fromISOString(workItem.getValue("attributeid"));
var currDate = new Date();
var Daydiff = dojo.date.difference(targetfixdate, currDate, "day");
if ( Daydiff < 1 ) {
return Status.OK_STATUS;
} else {
return new Status(Severity["ERROR"], "Target fixed date cannot be past date");
}
}
});
})();
Do you find any issue in the above script?
Comments
According to the posts from you you seem to have multiple issues with attribute customization. I cant say where all these scripts come from and where they break.
Not sure whether you actually locate the correct script. The error in the OP is
org.mozilla.javascript.EcmaError: TypeError: Cannot call method "getFullYear" of null ({"Bundle-SymbolicName":"org.dojotoolkit.dojo", "path":"\resources", "name":"date.js"}#224)Apparently, in your script there should be a line similar to "xxx.getFullYear" but "xxx" is null when the function is called.
This line seems questionable:
var targetfixdate = dojo.date.stamp.fromISOString(workItem.getValue("attributeid"));
What is "attributeid"? I'm guessing this is some kind of placeholder text that was supposed to be replaced, but has not yet been.
Nate is right. You should make sure "attributeid" is the right ID for the attribute "Target Fix Date". It appears that the variable "targetfixdate" is null when the function dojo.date.difference(targetfixdate, currDate, "day") is called, hence the error - the below screenshot show the exact line in dojo.date.js that throws this error.
2016-03-01 14:26:30,318 [WebContainer : 3 @@ 14:26 soalagappan <com.ibm.team.workitem.newworkitem Save@e6e831a7-8797-4719-89f0-064f2597ace2=""> /ccm/service/com.ibm.team.workitem.common.internal.rest.IWorkItemRestService/workItem2] ERROR com.ibm.team.workitem.common - Error invoking validator com.ibm.team.workitem.valueproviders.VALIDATOR._WPftQIBqEeWJZe1YTWhytQ
com.ibm.team.repository.common.TeamRepositoryException: Unexpected exception type.
Comments
You should find the changes that were made at the time when this error was thrown (user ID as well as the time you will find in the error message details) and using those data you can debug this script using Firebug.
In this case you should find which line in this script is affected that should help.
The issue is related with the attributes passing in the dojo.date.difference() function.
You should shift them and the one that can be NULL should be the second one as only the second one is optional.
Right now targetfixdate when is NULL you will see this error message as this script will end on the line where you are calculating day difference:
var Daydiff = dojo.date.difference(targetfixdate, currDate, "day");
More details about this function you will find here:
dojotoolkit guide
Please notice that:
// Returns the difference in the specified interval
date.difference(date1, date2, "week");
where:
date1 | Date | The first date for the difference. |
date2 | Date? | Optional argument The second date for the difference. Defaults to current Date. |