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

**URL:** <https://forum.inductiveautomation.com/t/sax2-driver-class-org-apache-xerces-parsers-saxparser/6620>\
**Category:** Ignition\
**Created:** [May 31, 2013, 5:32pm UTC](https://forum.inductiveautomation.com/t/sax2-driver-class-org-apache-xerces-parsers-saxparser/6620 "2013-05-31T17:32:19Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [August 3, 2021, 1:51pm UTC](https://forum.inductiveautomation.com/t/sax2-driver-class-org-apache-xerces-parsers-saxparser/6620/21 "2021-08-03T13:51:40Z")

</div>

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.

```auto
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

```auto
	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()

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/a/9a461a33b237c52bbdb4ab9a392b150b0bfda398.png)

Next onto Vision… no issues

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/c/2cd94e0d4a50fc1f7ee4200e2a9dbf801c32cdee.png)

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.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 3, 2021, 3:55pm UTC](https://forum.inductiveautomation.com/t/sax2-driver-class-org-apache-xerces-parsers-saxparser/6620/22 "2021-08-03T15:55:38Z")

</div>

> [@ryanjmclaughlin](#):
>
> Odd part is why can you not replicate it?

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.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [August 3, 2021, 4:05pm UTC](https://forum.inductiveautomation.com/t/sax2-driver-class-org-apache-xerces-parsers-saxparser/6620/23 "2021-08-03T16:05:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Isaac\_Hodgkins](https://avatars.discourse-cdn.com/v4/letter/i/59ef9b/32.png) [@Isaac\_Hodgkins](https://forum.inductiveautomation.com/u/Isaac_Hodgkins)\
**Post date:** [August 18, 2023, 2:46pm UTC](https://forum.inductiveautomation.com/t/sax2-driver-class-org-apache-xerces-parsers-saxparser/6620/24 "2023-08-18T14:46:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![scottmwyant](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/scottmwyant/32/66369_2.png) [@scottmwyant](https://forum.inductiveautomation.com/u/scottmwyant)\
**Post date:** [October 30, 2023, 7:31pm UTC](https://forum.inductiveautomation.com/t/sax2-driver-class-org-apache-xerces-parsers-saxparser/6620/25 "2023-10-30T19:31:11Z")

</div>

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.

```auto
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

```

@paul-griffith, any further information I could provide?

[Previous page](https://forum.inductiveautomation.com/t/sax2-driver-class-org-apache-xerces-parsers-saxparser/6620.md?page=1)
