JasperReports NoClassDefFoundError exception on net.sf.jasperreports.engine.util.JRStyledTextParser

Finally, I’ve got it working. I detected the root Exception, which was thrown before NoClassDefFoundError:net/sf/jasperreports/engine/util/JRStyledTextParser :

java.lang.NoClassDefFoundError: sun/awt/X11GraphicsEnvironment

The Sun AWT classes on Unix and Linux have a dependence on the X Window System. When you use these classes, they expect to load X client libraries and be able to talk to an X display server. This makes sense if your client has a GUI; unfortunately, it’s required even if your client uses AWT but does not have a GUI (which is my case, generating a report from a web application)

The way to bypass this, is setting a system property java.awt.headless=true on system startup.

Leave a Comment