ChartMacro - could not initialize class org.jfree.chart.JFreeChart

Update:

Tried to change the memory settings at “/etc/default/tomcat9”:
New: JAVA_OPTS="-Djava.awt.headless=true -XX:+UseG1GC -Xms1024m -Xmx2048m"

Restarted Tomcat afterwards:
-> Tomcat seems to ignore this parameters.
-> “ChartMacro” problem still exist

You can check that using something like

ps aux | grep java

where you will see if what you added is in the command line used to start Tomcat.

Hi Thomas,

thanks for your reply.

Yes, i mentioned that command in my previous post from yesterday.

I’ve also checked the “catalina.log” where i can’t find the “Xms” or “Xmx” parameters.

> ps aux | grep grep Djava

result for "Djava"

/usr/lib/jvm/java-8-openjdk-amd64/bin/java
-Djava.util.logging.config.file=/var/lib/tomcat9/conf/logging.properties
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.security.egd=file:/dev/./urandom
-Djdk.tls.ephemeralDHKeySize=2048
-Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
-Dignore.endorsed.dirs= -classpath /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar
-Dcatalina.base=/var/lib/tomcat9
-Dcatalina.home=/usr/share/tomcat9
-Djava.io.tmpdir=/tmp org.apache.catalina.startup.Bootstrap start

and

> ps aux | grep java

result for "java

/usr/lib/jvm/java-8-openjdk-amd64/bin/java
-Djava.util.logging.config.file=/var/lib/tomcat9/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.security.egd=file:/dev/./urandom
-Djdk.tls.ephemeralDHKeySize=2048
-Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
-Dignore.endorsed.dirs= -classpath /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar
-Dcatalina.base=/var/lib/tomcat9
-Dcatalina.home=/usr/share/tomcat9
-Djava.io.tmpdir=/tmp org.apache.catalina.startup.Bootstrap start

So it seems that the “JAVA_OPTS” parameter for “-Djava.security.egd=file:/dev/./urandom” is not ignored from “/etc/default/tomcat9” but the parameter for the memory settings.

Best regards,
Dolo

You are not setting JAVA_OPTS several times, are you ?

1 Like

Hi,

i do :roll_eyes:

Sorry, i am new to Java Servlets and Tomcat etc. :confused:

Should i place each parameter just into one “JAVA_OPTS” ?

Best regards,
Dolo

/etc/default/tomcat9 is actually a a bash script so when you set a variable it overwrite any content it previously had. You need to make sure you keep the previous content when you want to add more as in:

MYVAR="$MYVAR other stuff"

Or simply put everything in the same line.

1 Like

Hi,

thank you for this usefull instruction.

I’ve placed everything inside same line of JAVA_OPTS inside /etc/default/tomcat9.

Now tomcat starts with correct parameters:

ps aux | grep java
    /usr/lib/jvm/java-8-openjdk-amd64/bin/java 
    -Djava.util.logging.config.file=/var/lib/tomcat9/conf/logging.properties
    -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
    -Djava.awt.headless=true -XX:+UseG1GC -Xms1024m -Xmx2048m
    -Djava.security.egd=file:/dev/./urandom
    -Djdk.tls.ephemeralDHKeySize=2048
    -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
    -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
    -Dignore.endorsed.dirs= -classpath /usr/share/tomcat9/bin/bootstrap.jar:/usr/share/tomcat9/bin/tomcat-juli.jar
    -Dcatalina.base=/var/lib/tomcat9 -Dcatalina.home=/usr/share/tomcat9
    -Djava.io.tmpdir=/tmp org.apache.catalina.startup.Bootstrap start

Unfortunately this, dosn’t solve the actual “chartmacro” problem.
Will need to look for another possibilities.

Best regards,
Dolo

EDIT: grammar

Hi Vincent, Hi Thomas,

at first thank both of you for your constructive support and help!

I could solve the problem with the solution from Vincent.

Short Version:


  • I’ve installed XWiki in a test environment (VM - Ubunt 18.04)
    (As Ubuntu “.deb” package from repo: apt install xwiki-tomcat9-pgsql)

  • Configured the XWiki

  • Tested out the Chart macro -> Does not work with an clean install

  • Used Vincent’s solution from https://github.com/microsoft/vscode-arduino/issues/644
    Go to /etc/java-8-openjdk/accessibility.properties and comment out (deactivate) "assistive_technologies=org.GNOME.Accessibility.AtkWrapper"

  • Restart tomcat

  • Voilá - ChartMacro works

So maybe this solution can be somehow applied to the “.deb” package?

Thanks again!

Best regards,
Dolo

Long Version


  • Installation of XWiki on an Ubuntu 18.04 VM

    wget -q “https://maven.xwiki.org/public.gpg” -O- | sudo apt-key add -
    sudo wget “https://maven.xwiki.org/stable/xwiki-stable.list” -P /etc/apt/sources.list.d/
    sudo apt update
    apt-cache search xwiki
    sudo apt install xwiki-tomcat9-pgsql

  • Configuration

    sudo nano /etc/xwiki/xwiki.cfg

    => Added/Replaced values for:
    xwiki.authentication.validationKey=…
    xwiki.authentication.encryptionKey=…

    sudo nano /etc/default/tomcat9

    Add/change:
    JAVA_OPTS="-Djava.awt.headless=true -XX:+UseG1GC -Xms1024m -Xmx1024m -Djava.security.egd=file:/dev/./urandom"

  • configured “ShortURLs” - https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/ShortURLs/

    sudo cp /etc/tomcat9/Catalina/localhost/xwiki.xml /etc/tomcat9/Catalina/localhost/xwiki.xml.original
    sudo mv /etc/tomcat9/Catalina/localhost/xwiki.xml /etc/tomcat9/Catalina/localhost/ROOT.xml

    sudo nano /etc/xwiki/xwiki-tomcat9.xml

    OLD: <Context path="/xwiki" docBase="/usr/lib/xwiki" ...>
    NEW: <Context path="/" docBase="/usr/lib/xwiki" ...>

    sudo nano /etc/xwiki/xwiki.cfg

    -> uncomment/activate: "xwiki.webapppath="

    sudo systemctl restart tomcat9

  • Logged in and configured XWiki
    => XWiki Standard Flavor 11.10.2

  • Has not created SQL Indexes as mentioned at:
    https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Performances/Database%20Administration/
    => In the Main Wiki i’ve created the SQL indexes

  • Created a page with following content:

    {{chart type="pie" source="inline" params="range:B2-D5;series:columns;" title="Chart Test" width="320" height="240"}}
    |=|=X|=Y|=Z
    |Q1|1.2|3.4|1.3
    |Q2|4.5|3.4|2.3
    |Q3|1.2|4.5|9.0
    |Q4|3.4|1.2|1.2
    {{/chart}}
    

    Got an error on this page:
    Failed to execute the [chart] macro. Cause: [Assistive Technology not found: org.GNOME.Accessibility.AtkWrapper].
    -> Refresh page (F5) - got another error:
    "...java.lang.NoClassDefFoundError: Could not initialize class org.jfree.chart.JFreeChart..."

  • Tried out the solution from https://github.com/microsoft/vscode-arduino/issues/644

    sudo nano /etc/java-8-openjdk/accessibility.properties

    commendted out (deactivated):
    "assistive_technologies=org.GNOME.Accessibility.AtkWrapper"

    sudo systemctl restart tomcat9

    OK! Chart from the test page is now visible:
    ChartMacro_problem_solved1

  • Installed “Statistics Application 11.10.2”
    Activated "xwiki.stats" in "/etc/xwiki/xwiki.cfg"

    “xwiki.stats.default=1”

    sudo systemctl restart tomcat9

    OK! Chart at the “Current Month Activity” section is now also visible:

    ChartMacro_problem_solved2

End of Long version :slight_smile:

2 Likes

HI Vincent, @vmassol

Could you please share the solution at the comment section of the “chart macro” extension?

This topic can be closed as solved :slight_smile: :+1:

Thanks a lot!

Best regards,
Dolo

Would be great if you could crate a jira issue about that on https://jira.xwiki.org/browse/XWIKI with the details you indicated here.

Hi Thomas,

sure will create an jira issue for this.

Thanks!

Best regards,
Dolo

1 Like

Hi,

i’ve created an jira issue for this topic at:

https://jira.xwiki.org/browse/XWIKI-16993

Best regards,
Dolo

2 Likes

Thanks @Dolo.

Hi!
On debian 10.2 distribution x86-64 package java-11-openjdk this line already commented. In debian sid java-8-openjdk this line still uncommented.
Maybe you have to open bug at your linux distriro?

When I exporting PDF file,similar issue occured.I solved the issue following this method