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(JRFil开发者_JS百科ler.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
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.
I experienced the same issue and we've solved it by installing the xorg fonts packages along with the ttf fonts.
Text Parsing Exception means the font not have been recognized. I spent an whole day trying to understand why, then finally I fix this problem using text SansSerif. On Linux only a few font can be parsed. Hoping has helped, best regards
We had similar issue. we resolved it by using the jasper java flow jar file. the
java.awt.headless=true
didn't work for us.
This was due to a missing font. I was able to resolve this by installing fontconfig and urw-fonts packages.
yum install fontconfig
yum install urw-fonts
After that you can check supported fonts using command
fc-list
If the reports are still not generated you may need to reboot the server.
You get the same error if there is no enough space. I had the same error and it was because there was 0KB free space on server's hard drive.
I had the same issue and it was resolved by reducing the /tmp space. It was 100% (/tmp folder). I reduced it to 86% and restarted the server and the noclassdefinitionerror was gone and issue was resolved.
Faced this issue multiple times and I have got the solution. This error comes due to lack of memory space on disk... You can try below things to solve : (i) Make enough space in tmp folder (ii) Delete some unnecessary files on the disk to make some space.
Good luck..Hope.. it should solve your issue
Once you have this problem, googling will bring you here. For me the problem was Jdk 11.2.
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:84)
... 85 more
Caused by: java.lang.NullPointerException
at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1262)
at java.desktop/sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:225)
at java.desktop/sun.awt.FontConfiguration.init(FontConfiguration.java:107)
at java.desktop/sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:719)
at java.desktop/sun.font.SunFontManager$2.run(SunFontManager.java:367)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.SunFontManager.<init>(SunFontManager.java:312)
at java.desktop/sun.awt.FcFontManager.<init>(FcFontManager.java:35)
at java.desktop/sun.awt.X11FontManager.<init>(X11FontManager.java:56)
... 90 more
java.lang.InternalError: java.lang.reflect.InvocationTargetException
at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:86)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
at java.desktop/sun.java2d.SunGraphicsEnvironment.getFontManagerForSGE(SunGraphicsEnvironment.java:189)
at java.desktop/sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:223)
at java.desktop/sun.java2d.SunGraphicsEnvironment.getAvailableFontFamilyNames(SunGraphicsEnvironment.java:251)
at java.desktop/sun.java2d.HeadlessGraphicsEnvironment.getAvailableFontFamilyNames(HeadlessGraphicsEnvironment.java:75)
at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:94)
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:110)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:69)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)
at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:200)
at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:215)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:115)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:667)
Solutions tried
- Ran locally with JDK 11.02. No problems. Because the problems happens on linux 64 systems
- Ran on server -Djava-awt.headeless=true as suggested by some users . Problem still remains.
Reason this problem occurs is because support of certain fonts have been removed
From Oracle release notes https://www.oracle.com/technetwork/java/javase/11-relnote-issues-5012449.html#Removed
Removal of Lucida Fonts from Oracle JDK Oracle JDK no longer ships any fonts and relies entirely on fonts installed on the operating system.
This means that fonts in the Bigelow & Holmes Lucida family (Lucida Sans, Lucida Bright, and Lucida Typewriter) are no longer available to applications from the JDK.
If applications rely on fonts shipped in the JDK, they may need to be updated.
If system adminstrators are running Java server applications that rely on fonts shipped in the JDK rather than on system font packages, then the applications may fail to run until the system font packages are installed.
Go back to previous version of JDK or you can try upgrading Jasper.
for my case, jasperreports 6.8.0, worked the change of project dependency xml-apis from version
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>2.0.2</version>
</dependency>
to
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
</dependency>
as proposed in jaspersoft community forum https://community.jaspersoft.com/questions/825173/could-not-initialize-class-netsfjasperreportsengineutiljrstyledtextparser
I had to install the xfce4 font package in my alpine linux. In fact, I'm using docker. So, I put the following command in the dockerfile:
RUN apk add xfce4
Worked fine for me just installing the fontconfig library on the so.
apt install fontconfig
精彩评论