Caused by: java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which re

3

When trying to run a report containing a still image on an Amazon Linux server. The exception below appears. Has anyone ever been through this?

Caused by: java.awt.HeadlessException: No X11 DISPLAY variable was set, but
this program performed an operation which requires it. at 
java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204) at 
java.awt.Window.<init>(Window.java:536) at java.awt.Frame.<init>
(Frame.java:420) at java.awt.Frame.<init>(Frame.java:385) at 
javax.swing.JFrame.<init>(JFrame.java:189) at 
net.sf.jasperreports.view.JasperViewer.<init>(JasperViewer.java:267) at 
net.sf.jasperreports.view.JasperViewer.viewReport(JasperViewer.java:655) at 
net.sf.jasperreports.view.JasperViewer.viewReport(JasperViewer.java:587) at 
net.sf.jasperreports.view.JasperViewer.viewReport(JasperViewer.java:535) at 
util.report.ExecutorComprovante.execute(ExecutorComprovante.java:49) ... 51 
more
    
asked by anonymous 08.01.2016 / 01:02

2 answers

1

Often this type of error occurs when some code running outside a graphical environment, such as in your case on a server, attempts to execute something that uses a graphics library.

A good attempt is to install a Java headless . In Ubuntu you would do something like:

sudo apt-get autoremove openjdk-7-jre-headless
    
08.01.2016 / 18:35
1

Jasper Reports uses some awt functionality for image manipulation, but it does not require a "real" graphical environment to generate a report because nothing is actually sent to the display . To generate reports on servers with no graphical environment installed a known workaround is to run the JVM in headless mode, that is, to initialize the process of your application (or container, application, etc.) with:

-Djava.awt.headless=true 

Font Jaspersoft Community - Setting JVM Options for Application Servers

    
09.12.2016 / 10:54