I’m trying to run an RPC call from the client to the gateway to return a dataset, but I keep getting a deserialization error.
Here is my gateway implementation:
protected Dataset getRecordsImpl() {
List<CustomRecord> records = getCustomRecords(); // returns list of records from internal db
String[] names = {"Id", "Name", "Description"};
Class[] types = {Long.class, String.class, String.class};
Object[][] data = new Object[records.size()][3];
CustomRecord record;
for(int i=0; i < records.size(); i++) {
record = records.get(i);
data[i][0] = record.getId();
data[i][1] = record.getName();
data[i][2] = record.getDescription();
}
return new BasicDataset(Arrays.asList(names), Arrays.asList(types), data);
}
Stack Trace:
Java Traceback:
at org.python.core.Py.JavaError(Py.java:495)
at org.python.core.Py.JavaError(Py.java:488)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:430)
at org.python.core.PyObject.__call__(PyObject.java:371)
at org.python.core.PyObject.__call__(PyObject.java:375)
at org.python.pycode._pyx40.f$0(<buffer>:1)
at org.python.pycode._pyx40.call_function(<buffer>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1275)
at org.python.core.Py.exec(Py.java:1319)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)
at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89)
at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$InterpreterWorker.doInBackground(JythonConsole.java:419)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$InterpreterWorker.doInBackground(JythonConsole.java:407)
at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at javax.swing.SwingWorker.run(SwingWorker.java:334)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy26.getRecords(Unknown Source)
at com.tamakicontrol.modules.client.scripting.ClientRecordUtils.getRecordsImpl(ClientRecordUtils.java:39)
at com.tamakicontrol.modules.scripting.AbstractRecordUtils.getRecords(AbstractRecordUtils.java:70)
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)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
... 20 more
Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Unable to read response from Gateway.
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:329)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(GatewayInterface.java:432)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:265)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:260)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.moduleInvokeSafe(GatewayInterface.java:842)
at com.inductiveautomation.ignition.client.gateway_interface.ModuleRPCFactory$DynamicRPCHandler.invoke(ModuleRPCFactory.java:55)
... 28 more
Caused by: com.inductiveautomation.ignition.client.gateway_interface.ResponseParser$1: Error reading data element [row=1, column="Id", type=Long]
java.lang.NumberFormatException: For input string: "test.rptdesign"
at com.inductiveautomation.ignition.client.gateway_interface.ResponseParser.endElement(ResponseParser.java:293)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1776)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2964)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:504)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(GatewayInterface.java:430)
... 32 more
Caused by: java.lang.NumberFormatException: For input string: "test record"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:589)
at java.lang.Long.parseLong(Long.java:631)
at com.inductiveautomation.ignition.common.TypeUtilities.coerceLocaleSafe(TypeUtilities.java:777)
at com.inductiveautomation.ignition.client.gateway_interface.ResponseParser.endElement(ResponseParser.java:276)
... 43 more
Traceback (most recent call last):
File "<buffer>", line 1, in <module>
at com.sun.proxy.$Proxy26.getRecords(Unknown Source)
at com.tamakicontrol.modules.client.scripting.ClientRecordUtils.getRecordsImpl(ClientRecordUtils.java:39)
at com.tamakicontrol.modules.scripting.AbstractRecordUtilsUtils.getRecords(AbstractRecordUtils.java:70)
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)
java.lang.reflect.UndeclaredThrowableException: java.lang.reflect.UndeclaredThrowableException
Why am I getting a number format exception for a string column? Is there a better way to build datasets like this?