[2.0.5] xlrd: ClassNotFoundException ( org.apache.xerces.parsers.SAXParser )

Asked by reda benslal

hello.
i'm on a sikuli 2.0.5, openJDK 8, windows 7 64.
i'm running the following function that is supposed to do a .xlsx file comparaison.
__________________________________________________________________________________________________________________

def compare_xls1(xls1, xls2):
    rb1 = xlrd.open_workbook(xls1)
    rb2 = xlrd.open_workbook(xls2)
    i = 1
    sheet1 = rb1.sheet_by_index(0)
    sheet2 = rb2.sheet_by_index(0)

    for rownum in range(max(sheet1.nrows, sheet2.nrows)):
        if rownum < sheet1.nrows:
            row_rb1 = sheet1.row_values(rownum)
            row_rb2 = sheet2.row_values(rownum)

            for colnum, (c1, c2) in enumerate(izip_longest(row_rb1, row_rb2)):
                if c1 != c2:
                    Debug.user("[ERROR] Row {} Col {} - {} != {}".format(rownum+1, colnum+1, c1.encode('utf-8'), c2.encode('utf-8')))
                    i = 0
        else:
            Debug.user("[ERROR] Row {} missing".format(rownum+1))
            i = 0
    return i
__________________________________________________________________________________________________________________

the thing is, when i call for that function on a sikuli 2.0.5, the compiler throws back the following errors:

[error] script [ xlsx_test ] stopped with error in line 5
[error] java.lang.ClassNotFoundException ( org.apache.xerces.parsers.SAXParser )
[error] --- Traceback --- error source first
line: module ( function ) statement
91: expat ( __init__ ) self._reader = XMLReaderFactory.createXMLReader(_xerces_parser_name)
59: expat ( ParserCreate ) return XMLParser(encoding, namespace_separator)
1480: ElementTree ( __init__ ) parser = expat.ParserCreate(encoding, "}")
1205: ElementTree ( iterparse ) parser = XMLParser(target=TreeBuilder())
55: xlsx ( ensure_elementtree_imported ) ET.iterparse(_dummy_stream)
55: xlsx ( ensure_elementtree_imported ) ET.iterparse(_dummy_stream)
792: xlsx ( open_workbook_2007_xml ) ensure_elementtree_imported(verbosity, logfile)
130: __init__ ( open_workbook ) bk = xlsx.open_workbook_2007_xml(
8412: fct ( compare_xls1 ) rb1 = xlrd.open_workbook(xls1)
5: main ( <module> ) if fct.compare_xls1("C:\\Users\\W7_64_EN\\Desktop\\ATS_eZ\\Configurat
ions\\conf_***\\*******\\****-export.xlsx" , "C:\\Users\\W7_64_EN\\Desktop\\ATS_eZ\\Configurations\\conf_***\\*******_With_CI_Enabled\\****-export.xlsx") == 1:
[error] --- Traceback --- end --------------

but weirdly enough sikuli 1.1.2 seems to run it without any issues.
please, could it be a potential bug for 2.0.5 that induces such behaviour ? or there might be something in the function code that needs adjustment for 2.0.5?
looking forward to a reply , thank you in advance.
PS: i also tried upgrading OpenJDK to version 16 just in case, but it didn't seem to help much

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

I have no solution for you with the current implementation of SikuliX 2.0.5.

1. the bundled Jython slim version does not contain the Xerces project
2. Using Jython standalone 2.7.2 might not work, due to possible class path clashes
3. Jython 2.7.x generally has a problem using the Xerces project (this is due to a basic problem inside the SAX implementation in the Xerces project)

Nevertheless you might try, to run your scripts with Jython directly, having SikuliX on the class path (only needed if SikuliX features are used in the script).

Alternatively, you might delegate the xl... usage to a subprocess of native Python.

As a consequence I will remove the bundled xl... components from SikuliX in 2.0.6.
And 2.0.6 will have a solution, to use Jython standalone as the script runner from command line (which will restrict the useable SikuliX API to the core features)

Can you help with this problem?

Provide an answer of your own, or ask reda benslal for more information if necessary.

To post a message you must log in.