Apache POI returns java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

v8.1.25

I'm trying to build a proof of concept for breaking a Powerpoint file into images of the slides.

Unfortunately, when I try to draw the graphic, it throws the exception listed in the title. I'm thinking it was something deprecated and removed in Java 11, but I'm willing to be wrong.

I'd upload the generic 'Welcome to Powerpoint' file, but .pptx is not on the allowed extension list.

from java.awt import Color
from java.awt.geom import Rectangle2D
from java.awt.image import BufferedImage
from java.io import File;
from java.io import FileInputStream
from java.io import FileOutputStream
from org.apache.poi.xslf.usermodel import XMLSlideShow
from javax.imageio import ImageIO

filePath = "C:/Test/test.pptx"

pathList = filePath.split('/')
fileNameList = pathList[-1].split('.')
baseImagePath = '{}/{}_{}.{}'.format('/'.join(pathList[:-1]), '.'.join(fileNameList[:-1]), '{:02d}', 'png')


ppt = XMLSlideShow(FileInputStream(filePath))

pageSize = ppt.pageSize
slides = ppt.slides

for ndx, slide in enumerate(slides):
	image = BufferedImage(pageSize.width, pageSize.height,BufferedImage.TYPE_INT_RGB)
	imagePath = baseImagePath.format(ndx+1)
	
	graphics = image.graphics
	graphics.setPaint(Color.white)
	graphics.fill(Rectangle2D.Float(0, 0, pageSize.width, pageSize.height))
	slide.draw(graphics)
	
	fileOut = FileOutputStream(imagePath)
	ImageIO.write(image, 'png', fileOut)
	fileOut.close()
Java Traceback:
Traceback (most recent call last):
  File "<input>", line 29, in <module>
	at org.apache.poi.xslf.usermodel.XSLFSimpleShape.getGeometry(XSLFSimpleShape.java:729)
	at org.apache.poi.sl.draw.DrawSimpleShape.computeOutlines(DrawSimpleShape.java:381)
	at org.apache.poi.sl.draw.DrawSimpleShape.draw(DrawSimpleShape.java:74)
	at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:71)
	at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:50)
	at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:50)
	at org.apache.poi.sl.draw.DrawSlide.draw(DrawSlide.java:41)
	at org.apache.poi.xslf.usermodel.XSLFSlide.draw(XSLFSlide.java:373)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
	at org.python.core.Py.JavaError(Py.java:547)
	at org.python.core.Py.JavaError(Py.java:538)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:192)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:208)
	at org.python.core.PyObject.__call__(PyObject.java:477)
	at org.python.core.PyObject.__call__(PyObject.java:481)
	at org.python.core.PyMethod.__call__(PyMethod.java:141)
	at org.python.pycode._pyx356.f$0(<input>:22)
	at org.python.pycode._pyx356.call_function(<input>)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1687)
	at org.python.core.Py.exec(Py.java:1731)
	at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:277)
	at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:130)
	at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:611)
	at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:599)
	at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.desktop/javax.swing.SwingWorker.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
	at org.apache.poi.xslf.usermodel.XSLFSimpleShape.getGeometry(XSLFSimpleShape.java:729)
	at org.apache.poi.sl.draw.DrawSimpleShape.computeOutlines(DrawSimpleShape.java:381)
	at org.apache.poi.sl.draw.DrawSimpleShape.draw(DrawSimpleShape.java:74)
	at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:71)
	at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:50)
	at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:50)
	at org.apache.poi.sl.draw.DrawSlide.draw(DrawSlide.java:41)
	at org.apache.poi.xslf.usermodel.XSLFSlide.draw(XSLFSlide.java:373)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
	... 20 more
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
	at java.base/java.net.URLClassLoader.findClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	... 33 more
Traceback (most recent call last):
  File "<input>", line 29, in <module>
	at org.apache.poi.xslf.usermodel.XSLFSimpleShape.getGeometry(XSLFSimpleShape.java:729)
	at org.apache.poi.sl.draw.DrawSimpleShape.computeOutlines(DrawSimpleShape.java:381)
	at org.apache.poi.sl.draw.DrawSimpleShape.draw(DrawSimpleShape.java:74)
	at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:71)
	at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:50)
	at org.apache.poi.sl.draw.DrawSheet.draw(DrawSheet.java:50)
	at org.apache.poi.sl.draw.DrawSlide.draw(DrawSlide.java:41)
	at org.apache.poi.xslf.usermodel.XSLFSlide.draw(XSLFSlide.java:373)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

Anything change if you execute this in Gateway scope instead?

Is that JAXB exception something something Java EE?
Weird that it works at all, if that's the case, but I don't really know.

He's calling code that is trying to load an XML file via JAXB, and the assumption that JAXB would just "be there" stopped being valid in Java 11.

Java 11+ you need to include the JAXB libraries separately. It looks like we may include them in the Gateway, but not in the Client/Designer.

This is ultimately a failure of the POI library, or our version of it, in that it needs to declare explicit dependencies on a JAXB API and implementation. Later versions may already do that.

2 Likes

I would agree here. It does look they got got rid of the JAXB dependency in POI v5. Is v5 anywhere on the roadmap?

In the meantime, I'll try to take it through the gateway scope and see if that helps.

It's not formally on a roadmap but there is a ticket (IGN-5969) seeking to upgrade POI all the way to the latest v5 to eliminate some CVEs. So this might happen in the near future...

2 Likes

Thanks Joel, I'm going to back-burner this for now, as work is starting to get in the way. :wink:

Apache POI is now upgraded to 5.2.5. It will be in the 8.1 nightlies tonight.

4 Likes

Update:

Just spun up a VM with 8.1.38-rc1. Getting the same JAXB error in the designer, though it runs successfully in the gateway.

I can work with it, but it just makes things a bit more convoluted whilst working in vision.

We ended up reverting the POI version bump at the last minute, because it was causing other issues via a transitive dependency update. So no changes in 8.1.38, but should be in some 8.1 version "soon" :tm:

1 Like

Ah. Then I'm EagerlyAwaitingTM.

2 Likes

Just circling back for a moment. Would it be better to include JAXB in the Client/Designer, or just wait until the proper fix for the CVEs comes along?

Asking for a friend. :wink:

You could try including them as a temporary fix, but adding things to the lib/core folders is always a temporary fix, in that the next upgrade, or gateway backup and restore elsewhere, will require manual intervention to add them back again.

I wasn't meaning me, I'm too lazy. I was thinking IA in a future release. :crazy_face:

At this point though, it seems we're six of one and half-dozen of the other.

No dice. Among other reasons, new dependencies in that scope increase the amount of crap the Client/Designer has to download.

POI will get upgraded because of the CVE, it was just the timing that required a revert instead of a fix.

2 Likes