Hi there, yes, I know how to solve this problem
Add this code to the top of your script and it will work:
from org.python.core import imp
from java.lang import Thread
Thread.currentThread().setContextClassLoader(imp.getParentClassLoader())
Here is an explanation of the problem and solution:
This is a Classloader problem.
The expat.py module tries to load “org.python.apache.xerces.parsers.SAXParser” before it tries to load “org.apache.xerces.parsers.SAXParser” and fails.
Here’s the code I am talking about:
# Xerces
_mangled_xerces_parser_name = "org.python.apache.xerces.parsers.SAXParser"
_xerces_parser_name = "org.apache.xerces.parsers.SAXParser"
try:
self._reader = XMLReaderFactory.createXMLReader(_mangled_xerces_parser_name)
except:
self._reader = XMLReaderFactory.createXMLReader(_xerces_parser_name)
But both the client and designer can import “org.python.apache.xerces.parsers.SAXParser” just fine.
The problem is that the XMLReaderFactory.createXMLReader method in expat.py tries to load “org.python.apache.xerces.parsers.SAXParser” dynamically but looks in the wrong classloaders.
The reason this works in the designer is because in the designer the context classloader is set to a classloader that works. In the client the context classloader is set to null.
So you can get this to work in the client by setting the context classloader to the appropriate classloader.