I realize this forum isn’t the goto for all python questions, so I’m hoping I can ask this question with focus on the difference between Ignition Designer and Ignition Runtime.
I’m using xml.etree.cElementTree to parse an xml string and have found that it works well in the designer, but when I load it to the gateway, it errors on “org.xml.sax.SAXException: java.lang.ClassNotFoundException: org.python.apache.xerces.parsers.SAXParser”
I tried using the older xml.etree.ElementTree and got the same error.
Can anyone suggest what would cause this package to work correctly in the designer, but not runtime?
This is an example of the code.
from xml.etree.cElementTree import fromstring
import xml.etree.cElementTree as ET
from java.util import Date
root = ET.fromstring(system.tag.getTagValue("[Client]xmltag"))
header = ["t_stamp","Value"]
data = []
for child in root.findall('.//RPM_Messages/scan'):
data.append([child.attrib['rrTimestamp'],child.attrib['rrField1']])
event.source.parent.getComponent('Table').data=system.dataset.toDataSet(header, data)
I’ve also attached a sample project that demonstrates the issue.
It’s a project script module. In the demo I sent, I’m actually just calling a basic python script from the actionPerformed property.
So it should be executing on the client side, though right now I’m testing it on the same machine that I’m using as the gateway.
When I go to run mode in the designer, it works. When I run a client, I get errors. (Don’t worry - I’ve updated the gateway.)
Oh, bummer. I replaced etree with minidom in my project, which works, but it doesn’t seem as efficient or reliable. Any idea when/if you may be using the newer version of Jython?
I’ll make a feature ticket to upgrade the version of Jython Ignition uses. We’ll keep you updated here. Just keep in mind that even though we’ll update Jython, it still might not fix your particular problem.
I am having this problem…I am using the Script Console and I get a similar error…
Ignition Version 7.9.10 Trial Version
I am doing some very basic xml parsing and I keep running into an error:
oxml = """<PIM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.summitekinstruments.com" xsi:schemaLocation="http://www.summitekinstruments.com PIMXMLSchema.xsd">
<Responses Legacy="false">
<Response Action="GetProducts" Units="">
<Status Error="true" Code="0">
<Message>This session is not connected to an instrument</Message>
</Status>
</Response>
</Responses>
</PIM>
"""
from xml.etree import ElementTree as ET
root = ET.fromstring( oxml )
… and this yields the following error exactly every 10 runs …
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 org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:204)
at org.python.core.PyObject.__call__(PyObject.java:387)
at org.python.core.PyObject.__call__(PyObject.java:391)
at xml.parsers.expat$py.__init__$3(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py:139)
at xml.parsers.expat$py.call_function(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:194)
at org.python.core.PyFunction.__call__(PyFunction.java:387)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:220)
at org.python.core.PyMethod.__call__(PyMethod.java:211)
at org.python.core.PyMethod.__call__(PyMethod.java:206)
at org.python.core.Deriveds.dispatch__init__(Deriveds.java:19)
at org.python.core.PyObjectDerived.dispatch__init__(PyObjectDerived.java:1057)
at org.python.core.PyType.type___call__(PyType.java:1565)
at org.python.core.PyType.__call__(PyType.java:1548)
at org.python.core.PyObject.__call__(PyObject.java:404)
at org.python.core.PyObject.__call__(PyObject.java:408)
at xml.parsers.expat$py.ParserCreate$1(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py:59)
at xml.parsers.expat$py.call_function(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:149)
at org.python.core.PyFunction.__call__(PyFunction.java:327)
at xml.etree.ElementTree$py.__init__$81(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py:1160)
at xml.etree.ElementTree$py.call_function(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)
at org.python.core.PyBaseCode.call(PyBaseCode.java:194)
at org.python.core.PyFunction.__call__(PyFunction.java:387)
at org.python.core.PyFunction.__call__(PyFunction.java:381)
at org.python.core.PyInstance.__init__(PyInstance.java:120)
at org.python.core.PyClass.__call__(PyClass.java:194)
at org.python.core.PyObject.__call__(PyObject.java:371)
at org.python.core.PyObject.__call__(PyObject.java:375)
at xml.etree.ElementTree$py.XML$69(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py:977)
at xml.etree.ElementTree$py.call_function(C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyBaseCode.call(PyBaseCode.java:134)
at org.python.core.PyFunction.__call__(PyFunction.java:317)
at org.python.pycode._pyx31.f$0(<buffer>:15)
at org.python.pycode._pyx31.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:476)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$InterpreterWorker.doInBackground(JythonConsole.java:464)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
at org.xml.sax.helpers.XMLReaderFactory.loadClass(Unknown Source)
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source)
at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:186)
... 56 more
Caused by: java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
at java.net.URLClassLoader.findClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.sun.jnlp.JNLPClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.xml.sax.helpers.NewInstance.newInstance(Unknown Source)
... 62 more
Traceback (most recent call last):
File "<buffer>", line 15, in <module>
File "C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py", line 975, in XML
parser = XMLTreeBuilder()
File "C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\etree\ElementTree.py", line 1133, in __init__
self._parser = parser = expat.ParserCreate(None, "}")
File "C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py", line 59, in ParserCreate
return XMLParser(encoding, namespace_separator)
File "C:\Users\conno\.ignition\cache\gwlocalhost_8088_8043_main\C0\pylib\xml\parsers\expat.py", line 91, in __init__
self._reader = XMLReaderFactory.createXMLReader(_xerces_parser_name)
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
at org.xml.sax.helpers.XMLReaderFactory.loadClass(Unknown Source)
at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source)
at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
org.xml.sax.SAXException: org.xml.sax.SAXException: SAX2 driver class org.apache.xerces.parsers.SAXParser not found
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser