Ok, spent a bit more time replicating and narrowing down, 8.1.7 BTW. A few things learned:
- Does not seem to matter reading from file or reading from string
- If I loop the
et.fromstring()
it always occurs on the first iteration of the loop (which I guess would be expected with a classloader issue)
Using the following code in script console the java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
consistently occurs anywhere in 1-10 attempts.
import xml.etree.ElementTree as et
# Define as string
xml = """<?xml version="1.0" ?>
<__InSite __encryption="2" __version="1.1">
<__session>
<__useSession>
<user>
<__name>thedude</__name>
</user>
<sessionId __encrypted="no"></sessionId>
</__useSession>
</__session>
<__service __serviceType="OnlineQuery">
<__utcOffset>+08:00</__utcOffset>
<__txnGUID>ba55defe-00cc-4b30-888f-8761040294d5</__txnGUID>
<__inputData>
</__inputData>
<__requestData>
<CompletionMsg/>
<OnlineQuerySelection>
<__requestSelectionValuesEx/>
</OnlineQuerySelection>
</__requestData>
</__service>
</__InSite>"""
# Read from file
# xml = system.file.readFileAsString(r"C:\temp\debug.xml")
for x in range(10):
try:
et.fromstring(xml)
except:
raise
I thought it might be something related to project inheritance, so I created a virgin project (no inheritance) and ran this in script console and still occurred regularly. I cleared my .ignition cache and that also did not make any difference.
I created a quick test with an onActionPerformed
button in perspective and I cannot replicate the issue, no exceptions, so it seems Perspective context is fine
import xml.etree.ElementTree as et
# Define as string
xml = """<?xml version="1.0" ?>
<__InSite __encryption="2" __version="1.1">
<__session>
<__useSession>
<user>
<__name>thedude</__name>
</user>
<sessionId __encrypted="no"></sessionId>
</__useSession>
</__session>
<__service __serviceType="OnlineQuery">
<__utcOffset>+08:00</__utcOffset>
<__txnGUID>ba55defe-00cc-4b30-888f-8761040294d5</__txnGUID>
<__inputData>
</__inputData>
<__requestData>
<CompletionMsg/>
<OnlineQuerySelection>
<__requestSelectionValuesEx/>
</OnlineQuerySelection>
</__requestData>
</__service>
</__InSite>"""
# Read from file
# xml = system.file.readFileAsString(r"C:\temp\debug.xml")
try:
x = et.fromstring(xml)
perspective.statusInfo('%s %s' % (system.date.now(), str(x)))
except:
perspective.exceptionError()
Next onto Vision… no issues
So it does seem limited just to script console from what I can tell. Odd part is why can you not replicate it? I just checked the pylib folder to make sure my pylib was the same as the installer and it seems to be.