It's all about the answers!

Ask a question

Error Invoking Calculated Value Script


Cecil Beeland (1133) | asked May 28 '12, 9:10 p.m.
I'm attempting to develop a Calculated-Value Script for RTC 3.0.1.2 that will update an attribute based on a particular state change.

I have already run into the issue where workItem.getValue(WorkItemAttributes.STATE) always seems to return null. However, (for better or worse) I've found a workaround using workItem._proxy.object.attributes.internalState.label.
I've come across a few posts in the forum where people have identified the issue of WorkItemAttributes.STATE being null. However, I didn't see any agreement on what the underlying issue was.

Additionally, the script fails to run at all on save (as well as if I set Status as a dependency for the attribute). After further investigation, I found this error in the ccm log:

2012-05-28 20:54:25,520 ERROR com.ibm.team.workitem.common - Error invoking value provider 'com.ibm.team.workitem.valueproviders.VALUE_PROVIDER._Z1bfoKa6EeGhdfd81nRvQA'
com.ibm.team.repository.common.TeamRepositoryException: Unexpected exception type
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.handleException(ScriptAttributeValueProvider.java:229)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.getValue(ScriptAttributeValueProvider.java:64)
at com.ibm.team.workitem.common.internal.attributeValueProviders.AttributeValueProviderRegistry$SafeValueProvider.getValue(AttributeValueProviderRegistry.java:43)
at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.getValue(AttributeImpl.java:898)
at com.ibm.team.workitem.common.internal.WorkItemCommon.createWorkItem(WorkItemCommon.java:221)
at com.ibm.team.workitem.common.internal.WorkItemCommon.createWorkItem2(WorkItemCommon.java:176)
at com.ibm.team.workitem.service.internal.rest.WorkItemRestService.createWorkItem(WorkItemRestService.java:2048)
at com.ibm.team.workitem.service.internal.rest.WorkItemRestService.getWorkItem(WorkItemRestService.java:1748)
at com.ibm.team.workitem.service.internal.rest.WorkItemRestService.getValues(WorkItemRestService.java:1330)
at sun.reflect.GeneratedMethodAccessor1105.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:370)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:356)
at org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
at $Proxy776.getValues(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1104.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.doModelledRestService(AbstractTeamServerServlet.java:504)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest2(AbstractTeamServerServlet.java:1869)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest(AbstractTeamServerServlet.java:1725)
at com.ibm.team.repository.servlet.AbstractTeamServerServlet.service(AbstractTeamServerServlet.java:1634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:120)
at com.ibm.team.repository.server.servletbridge.JazzServlet.service(JazzServlet.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:420)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:879)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:811)
Caused by:
org.mozilla.javascript.EcmaError: TypeError: Cannot read property "object" from undefined (updateDefectTimesReopened.js#14)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3557)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3535)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3563)
at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3582)
at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3595)
at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1381)
at org.mozilla.javascript.gen.c1014._c2(updateDefectTimesReopened.js:14)
at org.mozilla.javascript.gen.c1014.call(updateDefectTimesReopened.js)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3003)
at org.mozilla.javascript.gen.c1014.call(updateDefectTimesReopened.js)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler$MethodHandler$1.run(AbstractInvocationHandler.java:160)
at com.ibm.team.rtc.common.scriptengine.environment.AbstractScriptEnvironment.execute(AbstractScriptEnvironment.java:74)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler$MethodHandler.invoke(AbstractInvocationHandler.java:156)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler.invokeGeneric(AbstractInvocationHandler.java:141)
at com.ibm.team.rtc.common.scriptengine.internal.bridge.proxy.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:95)
at $Proxy2383.getValue(Unknown Source)
at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.getValue(ScriptAttributeValueProvider.java:62)
... 46 more


I have checked the usual issues (scripts being enabled on the server, WorkItemAttributes being defined as com.ibm.team.workitem.api.common.WorkItemAttributes) and have not been able to resolve the issue. I have even been able to set an arbitrary dependency (ex: the planned for field), made a change to that field, and seen the script execute successfully.

I'm somewhat at a loss as to the issue here. I'm not sure if its a limitation/defect in this version of RTC or if it may be an issue with my code. I can post the script; However, it is fairly simple, and as I stated earlier, it will execute under different circumstances.

Any thoughts?

2 answers



permanent link
Ralph Schoon (60.5k33643) | answered May 29 '12, 2:29 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,

have you tried to add the state attribute as dependency to the attribute that has the value provider? I got the "null" when I didn't.

I am not aware that there is a way to get the old state value (to determine that there is a state change). You would have to calculate the value every time.

If you happen to run into how the old state can be accessed, please publish it here.

permanent link
Cecil Beeland (1133) | answered May 29 '12, 1:28 p.m.
Hi,

have you tried to add the state attribute as dependency to the attribute that has the value provider? I got the "null" when I didn't.

I am not aware that there is a way to get the old state value (to determine that there is a state change). You would have to calculate the value every time.

If you happen to run into how the old state can be accessed, please publish it here.


Yes, I've tried adding the 'Status' attribute as a dependency to the value provider and still get the Null value.

In my prodding around behind the scenes a bit, I had noticed that the _proxy.object.attributes.* seemed to represent the current values of attributes, and the _proxy.storedObject.attributes.* seemed to represent the current saved values of the work item attributes. It was there that I was hoping to identify the old state.
This theory does seem to hold true for some/most attributes. However, upon further observation, it does not hold true for the internalState attribute.

The further I dig into this, the more I get the impression that the scripting framework simply isn't well enough developed (as of 3.0.1.2) to get the functionality that I was hoping for...

Your answer


Register or to post your answer.