Apache POI error when not in IDE

2019-08-27 15:37发布

问题:

We are using Apache POI to create a very simple spreadsheet. Everything works in the development environment. When released, the project is exported as a runnable JAR; this jar and all required libraries are placed on a central server. The various PCs all reference these same files.

On most PCs (Linux and Win7), everything works. On a minority of Win7 machines, however, we receive the error:

DOMSource cannot be processed: check that saxon9-dom.jar is on the classpath.

I have tried adding the -D option as suggested here, to no avail. In any case, it's unclear why the dependencies should break only on certain machines. Could there be a difference in the order that the libraries are loaded?

I have also tried extracting all dependencies into the exported the jar file. This (very fat!) jar file work - or doesn't work - on exactly the same machines.

I am at a loss: what could cause Apache POI to fail in this way on certain machines?

回答1:

This turns out to have been a problem with an older version of LibreOffice (specifically, the affected systems were still running version 3.6). Updating to LibreOffice 5.0 resolved the issue.

Exactly how/why LibreOffice was affecting the XML processing in Apache POI is unclear. At any rate, it is now unimportant.