Cannot call method "getDataConnector" error
I'm getting the error below. Is anyone familiar with it and can suggest some solutions? Thanks!
org.mozilla.javascript.EcmaError: TypeError: Cannot call method "getDataConnector" of undefined (CalculatedValueSkeleton.js#19)
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.undefCallError(ScriptRuntime.java:3601)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2160)
at org.mozilla.javascript.gen.c253._c2(CalculatedValueSkeleton.js:19)
at org.mozilla.javascript.gen.c253.call(CalculatedValueSkeleton.js)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
at org.mozilla.javascript.gen.c253._c3(CalculatedValueSkeleton.js:44)
at org.mozilla.javascript.gen.c253.call(CalculatedValueSkeleton.js)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2347)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:272)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:127)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
org.mozilla.javascript.EcmaError: TypeError: Cannot call method "getDataConnector" of undefined (CalculatedValueSkeleton.js#19)
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.undefCallError(ScriptRuntime.java:3601)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2160)
at org.mozilla.javascript.gen.c253._c2(CalculatedValueSkeleton.js:19)
at org.mozilla.javascript.gen.c253.call(CalculatedValueSkeleton.js)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:119)
at org.mozilla.javascript.gen.c253._c3(CalculatedValueSkeleton.js:44)
at org.mozilla.javascript.gen.c253.call(CalculatedValueSkeleton.js)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2347)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:272)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:127)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
2 answers
Hi David, Thanks for responding. I was invoking the getFilteredValueSet method from another class. I'm trying to find a way to return a calculated value and still use the HttpConnector. See code sample below.
dojo.provide("org.example.workitems.providers.CalculatedValueSkeleton");
dojo.require("com.ibm.team.workitem.api.common.connectors.HttpConnectorParameters");
(function() {
var HttpConnectorParameters= com.ibm.team.workitem.api.common.connectors.HttpConnectorParameters;
dojo.declare("myclass",null,{
getFilteredValueSet: function(attributeId, workItem, context, filter) {
var params= new HttpConnectorParameters();
params.url= myURL;
params.xpath= "//srnumber";
params.columnXpaths= ["./nextnumber/@data"];
params.columnIds= ["nextnumber"];
var connector= context.getDataConnector("HttpConnector");
var values= connector.get(params);
var result= [];
var srnumber = "";
while(values.hasNext()){
var entry= values.next();
var nextsrnumber= entry.getById("nextnumber");
if (nextsrnumber.indexOf(filter) > -1) {
result.push(nextsrnumber);
srnumber = nextsrnumber;
}
}
return srnumber;
}
});
dojo.declare("org.example.workitems.providers.CalculatedValueSkeleton", myclass, {
constructor: function(attributeId, workItem, context, filter) {
var srnvalue = new myclass();
this.srnumber = srnvalue.getFilteredValueSet();
},
getValue: function(attributeId, workItem, configuration) {
return this.srnumber;
}
});
})();
dojo.provide("org.example.workitems.providers.CalculatedValueSkeleton");
dojo.require("com.ibm.team.workitem.api.common.connectors.HttpConnectorParameters");
(function() {
var HttpConnectorParameters= com.ibm.team.workitem.api.common.connectors.HttpConnectorParameters;
dojo.declare("myclass",null,{
getFilteredValueSet: function(attributeId, workItem, context, filter) {
var params= new HttpConnectorParameters();
params.url= myURL;
params.xpath= "//srnumber";
params.columnXpaths= ["./nextnumber/@data"];
params.columnIds= ["nextnumber"];
var connector= context.getDataConnector("HttpConnector");
var values= connector.get(params);
var result= [];
var srnumber = "";
while(values.hasNext()){
var entry= values.next();
var nextsrnumber= entry.getById("nextnumber");
if (nextsrnumber.indexOf(filter) > -1) {
result.push(nextsrnumber);
srnumber = nextsrnumber;
}
}
return srnumber;
}
});
dojo.declare("org.example.workitems.providers.CalculatedValueSkeleton", myclass, {
constructor: function(attributeId, workItem, context, filter) {
var srnvalue = new myclass();
this.srnumber = srnvalue.getFilteredValueSet();
},
getValue: function(attributeId, workItem, configuration) {
return this.srnumber;
}
});
})();
Hi Alicia,
are you able to get Connector Object, i am still getting "getDataConnector" error".
Please help.
are you able to get Connector Object, i am still getting "getDataConnector" error".
Please help.
Comments
Yes, I was able to get it to work. I imported myURL client certificate into the tomcat keystore.
Alicia
Hi Alicia,
Can you please elaborate on what you did to resolve this issue.. I have a similar requirement. I need to have a scripted calculated value that relies on a REST call (Data Connector).
Thanks.
Was anyone able to resolve this issue using the code provided in this thread. The certificate issue I believe could be resolved by setting ignoreInvalidCertificates flag to "true" for params. However, the context is still undefined and getConnectorData is failing.
I would appreciate any input on this.
Thanks.
Comments
David Olsen
JAZZ DEVELOPER Jun 21 '12, 3:28 p.m.What were you trying to do when you got the error? Where does the error message appear?