Open Jasper Reports report on Web Server

Asked

Viewed 728 times

0

I cannot open my reports on the Web Server, after deploy.

My project is java Hibernate with Maven.

When I try to print a report I get this log from Tomcat:

Log of the Tomcat

19-Aug-2017 20:35:32.050 WARNING [http-nio-8080-exec-10] com.sun.faces.lifecycle.InvokeApplicationPhase.execute java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser
javax.el.ELException: java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser
at org.apache.el.parser.AstValue.invoke(AstValue.java:260)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267)
at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:149)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:814)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:104)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:72)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:60)
at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:201)
at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:216)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:85)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:286)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:759)
at br.com.emporio.financeirocasatua.bean.DespesaBean.imprimirOutros(DespesaBean.java:1571)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.el.parser.AstValue.invoke(AstValue.java:247)
... 33 more

19-Aug-2017 20:35:32.060 SEVERE [http-nio-8080-exec-10] com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:104)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:72)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:60)
at net.sf.jasperreports.engine.fill.JRFiller.createBandReportFiller(JRFiller.java:201)
at net.sf.jasperreports.engine.fill.JRFiller.createReportFiller(JRFiller.java:216)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:85)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:286)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:759)
at br.com.emporio.financeirocasatua.bean.DespesaBean.imprimirOutros(DespesaBean.java:1571)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.el.parser.AstValue.invoke(AstValue.java:247)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267)
at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:149)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:814)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1455)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

My code to call the report:

public void imprimirOutros() {

    try {

        if (filtro.getDataEntradaInicial() == null || filtro.getDataEntradaFinal() == null) {
            Messages.addGlobalInfo("Favor preencher os campos");
            return;
        } else {

            String recDataEntradaInicial = filtro.getDataEntradaInicialFormatada();
            String recDataEntradaFinal = filtro.getDataEntradaFinalFormatada();

            HashMap<String, Object> parametros = new HashMap<String, Object>();

            parametros.put("DESPESA_DATA_ENTR_INICIAL", recDataEntradaInicial);
            parametros.put("DESPESA_DATA_ENTR_FINAL", recDataEntradaFinal);

            String caminho = null;
            switch (filtro.getRelatorio()) {
            case ("Nota Sem Boleto"):
                caminho = Faces.getRealPath("/reports/Despesa_NotaSemBoleto.jasper");
                break;
            case ("Vale"):
                caminho = Faces.getRealPath("/reports/Despesa_Vale.jasper");
                break;
            case ("Transferencia"):
                caminho = Faces.getRealPath("/reports/Despesa_Transferencia.jasper");
                break;
            case ("Bonificacao"):
                caminho = Faces.getRealPath("/reports/Despesa_Bonificacao.jasper");
                break;
            case ("Sistema Tributario"):
                caminho = Faces.getRealPath("/reports/Despesa_SistemaTributario.jasper");
                break;
            case ("Cheque"):
                caminho = Faces.getRealPath("/reports/Despesa_Cheque.jasper");
                break;
            case ("Datas Divergentes"):
                caminho = Faces.getRealPath("/reports/Despesa_DatasDivergentes.jasper");
                break;
            case ("X1"):
                caminho = Faces.getRealPath("/reports/Despesa_X1.jasper");
                break;
            default:
                caminho = "Este tipo de relatorio não existe";
                break;
            }

            Connection conexao = HibernateUtil.getConexao();

            JasperPrint jpPrint = JasperFillManager.fillReport(caminho, parametros, conexao);
            JasperViewer jv = new JasperViewer(jpPrint, false);
            jv.setVisible(true);
        }
    } catch (JRException erro) {
        Messages.addGlobalError("Ocorreu um erro ao tentar gerar o relatório Outros");
        erro.printStackTrace();
    }

}

1 answer

1

According to the Troubleshooting jasperreport:

This error is normally Associated with a JVM not being Started on a Linux machine in AWT headless mode. Jasperreports Server doesn’t provide a virtual X frame buffer on Linux. To Prevent Java from trying to connect to an X-Server for image Processing in JRS [...]

And it prompts you to first try modifying your server startup script by including the following JAVA_OPTS:

-Djava.awt.headless=true

In this topic on Soen a user claims to have solved the problem in a similar way to the above, only in Java code, by setting a system property on startup.

System.setProperty("java.awt.headless", "true");

Already in this another topic user claims to have solved by adding the xml-apis dependency.

Other possible causes, according to the community are:

  • For some reason one or more jars are missing from the Jasperreports Server installation (The jars below are considered the minimum);

Jasperreports-X.X.X.jar (Current version 6.4.1)
Commons-digester-X.X.jar (Current version 2.1)
Commons-Collections-X.X.jar (Current version 3.2.2)
Commons-javaflow-20160505.jar
Commons-logging-X.X.X.jar (Current version 1.1.1)
Commons-beanutils-X.X.X.jar (Current version 1.9.3)
iText-2.1.7.jsX. jar (used for exporting current version pdf 2.1.7.js6)

  • One or more standard system sources are not available in the environment.

The cause of this problem is not very clear (like many things involving jasperreports) so if nothing goes right try one of the solutions proposed in this thread in Soen with various solutions targeted by users.

  • Thank you Gustavo for answering.

  • I’ll test with these options you put in and I’ll come back with the result.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.