SAX2 driver class org.apache.xerces.parsers.SAXParser

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.

432 attempts later, I got it to occur on a real build in a Docker container. ~1500 attempts and I still haven't gotten it to happen in a build out of the IDE - that's probably why we're having a hard time replicating in house. The IDE is doing...something, that prevents it from being an issue, and it happens infrequently enough QA didn't hit it on Docker builds. I'll file a new ticket since we've got a good SSCCE now.

Wow, yeah that’s weird the difference in frequency is amazing. Thanks for staying on this, it’s important for us as our MES is all XML communication. Let me know if you need any more info or need fixes tested.

I had this problem and this fix still works for me.

This is still relevant in 8.1.19. I will do some homework and provide details. I've only ever seen this show up in the Script Console. I have a routine that I work with frequently that gets XML data from an API. Doing any manual testing in the script console and I always come across this. The odd thing is it happens twice in a row, then resolves, so the third press of the "Execute" button works. I've dealt with this for probably 18mo now, as it's just a few more clicks.

Edit: Remembered to come back with some detail. The following code is intended to be run from the script console (I'm using a designer connected to a remote Gateway). Provide any xml file. The script will execute as expected 8 consecutive times, fail the 9th and 10th time, then work another 8 times, etc. This pattern is very consistent.

import xml.etree.ElementTree as ET
xmlFile = "C:\Users\user\Downloads\some.xml"
xmlString = system.file.readFileAsString(xmlFile)
root = ET.fromstring(xmlString)
print root.tag

@PGriffith, any further information I could provide?