Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

When trying to export on WebLogic 11g, it throws NoClassDefFound exception. I checked the application WAR and jasperreports-3.7.4.jar is included in WEB-INF/lib folder. What is the error?

StackTrace

java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/util/JRStyledTextParser at net.sf.jasperreports.engine.fill.JRBaseFiller.(JRBaseFiller.java:181) at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:76) at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:86) at net.sf.jasperreports.engine.fill.JRVerticalFiller.(JRVerticalFiller.java:56) at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:142) at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:78) at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624) at org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView.fillReport(AbstractJasperReportsView.java:676) at

like image 359
Esteve Camps Avatar asked Sep 02 '10 14:09

Esteve Camps


2 Answers

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.

like image 61
Esteve Camps Avatar answered Sep 18 '22 22:09

Esteve Camps


I experienced the same issue and we've solved it by installing the xorg fonts packages along with the ttf fonts.

like image 37
rudygodoy Avatar answered Sep 19 '22 22:09

rudygodoy