0

Im working in a Web application that allow the user to create and see the information from database with a JasperReports's report. The JasperReports works and I can see the copy in the server side.

The problem appears when I want to show the results to client in his computer. The application send me a java.awt.HeadlessException because of AWT library that JasperReports use.

public void createView(){
        jasperViewer = new JasperViewer (reportFilled);
        jasperViewer.setVisible(true);
    }

Its a very easy code, but I don't know how to fix this problem or its possible to use other libraries.

Some one can help me with other idea or know how to solve this?

Alex K
  • 22,315
  • 19
  • 108
  • 236
Jorge A
  • 19
  • 5
  • This exception occurs only when you run a code in a non-awt environment such as servers. are you sure that you run the code at client side. – mfidan Jul 11 '16 at 13:40
  • It is used in a server. The code its written in a JSF bean and the method is called when client click in a button. The report is created and seved as a file, but when i want to use the JasperViewr crash. ¿there are other way to let the client show the report? – Jorge A Jul 11 '16 at 14:06
  • Jasperviewer is a swing based viewer component. in a jsf application you must convert jasperreport to html to view in a web page. – mfidan Jul 11 '16 at 14:09
  • hope answer below helpfull. – mfidan Jul 11 '16 at 14:34
  • Its very difficult to find some answrs at this page becouse people make different questions. The option that you bring me, its near the solution then I can say that help me. Thanks for all. – Jorge A Jul 12 '16 at 10:17

1 Answers1

0

This exception occurs only when you run a code in a non-awt environment such as servers. Take a look at link below about the solution.

How do I prevent a headless exception in Java?

If you want to run report in a server environment then show user in a web page you must convert to jasper print to html. take a look this answer for how to do that.

View report using JasperViewer or something else in web application

Community
  • 1
  • 1
mfidan
  • 647
  • 5
  • 19