10

When Jenkins tries to generate the Performance Trends graphs there launches several exceptions always with root cause: "java.lang.NoClassDefFoundError: Could not initialize class org.jfree.chart.JFreeChart"

This is what I did:

  • desployed Jenkins , tried with v1.532.2 (stable) and also with v1.539-SNAPSHOT
    • didn't configured security
    • just set paths to my JDK (oracle's jdk1.7.0_51), MAVEN (3.1.1) and GIT (1.8.1.2)
  • enabled these plugins:
    • Checkstyle v3.39
    • Jenkins Cobertura v1.9.3
    • FindBugs v4.51
    • Warnings v4.39
    • PMD v3.38
    • Performance v.1.10
    • Jenkins Git client v1.6.2
    • Jenkins Git 2.0.1

Then I created a project which successfully creates a JMeter report file from my Java webapp using the plugin jmeter-maven-plugin v1.9.0, but there doesn't appear the Performance Trend graphs on the project's page. Jenkins really gathers the results because it shows me the response times, but can't show me the graphs. There launches several Exceptions always with root cause: "java.lang.NoClassDefFoundError: Could not initialize class org.jfree.chart.JFreeChart" . Here you will find a complete StackTrace: http://pastebin.com/uhiNR7XD

Jenkins already has jcommon-1.0.12.jar and jfreechart-1.0.9.jar at it's /WEB-INF/lib/ . This other post doesn't apply.

Can you help me, please?

Thanks in advance!

/ Angel

Community
  • 1
  • 1
Angel
  • 940
  • 1
  • 9
  • 21

5 Answers5

12

Angels Answer is correct, you have to add -Djava.awt.headless=true.

However, in my case it wasn't enough: I was running Jenkins on openjdk-8-jre-headless (Debian), which doesn't contain some libraries that JFreeChart requires.

Solution: use openjdk-jre-8 instead of openjdk-jre-8-headless.

Just an additional note to the people arriving from search engines.

Community
  • 1
  • 1
0x89
  • 2,940
  • 2
  • 31
  • 30
  • I can't imagine why using a headless runtime can be a cause to this problem. In my case it wasn't the cause, it was the solution. – Angel Jan 03 '17 at 15:49
  • I can assure you that the problem can *also* be caused by running on a headless jdk. If you do not believe me, just fetch yourself a debian VM and try it. I don't want to say that your answer is false - just in my case, it wasn't enough to get rid of the error. – 0x89 Jan 05 '17 at 09:49
  • 1
    I believe it, but I can't imagine why using a headless runtime can cause the problem :) With your edit I understand that the headless JRE doesn't provide something that JFreeChart requires, but It would be nice to have time to reproduce it and see what's missing, maybe you could make it work even if with a headless JRE. Best regards /Ángel – Angel Jan 06 '17 at 11:13
  • 1
    You could be right, it might actually be sufficient to install libfontconfig1, see https://github.com/docker-library/openjdk/issues/46. However, for now I am fine with installing a non-headless jre :-) – 0x89 Jan 09 '17 at 17:09
  • 2
    In my case it ended up being https://bugs.debian.org/798794 (https://askubuntu.com/a/723503). Adding "RUN sed -i 's/^assistive_technologies=/#&/' /etc/java-8-openjdk/accessibility.properties" to my Dockerfile fixed it. :) – tianon Jul 07 '17 at 04:24
6

Solved! Somebody helped me to solve it here : https://groups.google.com/forum/#!topic/jenkinsci-users/o_Dr7Tn0i3U

It's not a bug in Jenkins but a miss-configuration. The solution is just adding -Djava.awt.headless=true to Jenkin's runtime.

I'm running Jenkins as a webapp on my Tomcat, then I just added this line to my /opt/tomcat/bin/catalina.sh : CATALINA_OPTS=-Djava.awt.headless=true

I wanted you to share this solution. Cheers from Barcelona.

/ Angel

Angel
  • 940
  • 1
  • 9
  • 21
  • This happens for me even with `-Djava.awt.headless=true` - and of course all that can be found on the internet is this solution.. – 0x89 Aug 17 '16 at 11:55
  • Hi! Please, show your versions and configuration, as I did. Best regards, /Ángel – Angel Aug 19 '16 at 14:54
1

On a Debian 9 installation I was able to fix this problem by installing the libjfreechart-java package:

sudo apt-get install libjfreechart-java

I found this solution in the relevant Jenkins bug report: JENKINS-39636

Alexander Köplinger
  • 2,497
  • 17
  • 15
roelvanmeer
  • 356
  • 4
  • 18
1

On Debian 10.3 with openjdk-8-jre-headless the fix is to comment the assistive_technologies line in /etc/java-8-openjdk/accessibility.properties, as pointed out by @tianon and the first commenter in the Jenkins issue, linked to from the first answer (JENKINS-39636).

Max Leske
  • 5,007
  • 6
  • 42
  • 54
0

My java.awt.headless is already true. So I carefully checked this link and found the solution which works perfectly fine for me:

ubuntu

sudo apt-get install libfontconfig

centos

yum install libXext libXrender fontconfig libfontconfig.so.1
Andy Wang
  • 677
  • 1
  • 6
  • 10