30

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

Alex K
  • 22,315
  • 19
  • 108
  • 236
Esteve Camps
  • 1,113
  • 1
  • 10
  • 20
  • Isn't there a root cause? Look further in the trace. Initialization of the class might have plain failed. – BalusC Sep 02 '10 at 14:53
  • Are there multiple jasperreport jars in the web app or classpath. – JoseK Sep 03 '10 at 06:52
  • @JoseK It seems that only one jar exists on classpath. I tried to deploy this WAR without Jasperreport.jar in it, but it throws exception for NoClassDefFound on Jasper classes. – Esteve Camps Sep 03 '10 at 08:47
  • It might be cached in the tmp_delete folders within the weblogic domain - can you delete all that and try? – JoseK Sep 03 '10 at 09:16

12 Answers12

33

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.

Alex K
  • 22,315
  • 19
  • 108
  • 236
Esteve Camps
  • 1,113
  • 1
  • 10
  • 20
  • 2
    Has anyone had trouble using the java.awt.headless=true solution on different machine? It is working for us on one of our deployments, while not working on another. Both of the deployments are using the same JVM version. – Master.Aurora Jun 05 '14 at 10:35
  • Worked to me! My server is the [Weblogic 12c](http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html). I added the `-Djava.awt.headless=true` value in server initialize arguments, exactly in Server Resume tab. – Janderson Silva Aug 28 '17 at 15:50
4

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

rudygodoy
  • 438
  • 3
  • 8
2

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

Lorenzo
  • 21
  • 1
1

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.

j0k
  • 22,600
  • 28
  • 79
  • 90
Tony A
  • 11
  • 1
  • 5
    Could you please share some details as to how you achieved this? I'm having the same problem and I tried using the java flow jar but that's not working either for me. Is there something I'm missing? – user1066568 May 27 '13 at 07:39
  • where exactly need to add this line? – Elango Mani Sep 26 '14 at 09:00
  • @Elango You need to set the java.awt.headless property to true. That can be done using: static { System.setProperty("java.awt.headless", "true"); } Or, by setting the headless property in your tomcat startup command as -Djava.awt.headless=true – kozla13 Nov 24 '14 at 10:23
1

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.

Ruchira Nawarathna
  • 1,137
  • 17
  • 30
0

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.

drinovc
  • 521
  • 5
  • 16
0

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.

0

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

0

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.

vsingh
  • 6,365
  • 3
  • 53
  • 57
0

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

AntimoV
  • 51
  • 1
  • 5
0

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
gianlucaparadise
  • 1,678
  • 20
  • 32
Davi Carrano
  • 331
  • 2
  • 4
0

Worked fine for me just installing the fontconfig library on the so.

apt install fontconfig
rodrigomelo
  • 59
  • 1
  • 1
  • 3