Jasperprint Ireport

Asked

Viewed 343 times

2

Why the following statement runs on Windows and not linux?

JasperPrintManager.printReport(relatorio, true);

In the window open the printer dialog, but under Linux show the next error:

net.sf.jasperreports.engine.Jrexception: Report print error.

Method:

public void imprimir() {
        try {
            //Navegar na arvore da aplicacao
            DataTable tabela = (DataTable) Faces.getViewRoot().findComponent("formListagem:tabela");
            Map<String, Object> filtros = tabela.getFilters();

            String razaoInstituicao = (String) filtros.get("razaosocial");
            String cnpjInstituicao = (String) filtros.get("cnpj");

            String caminho = Faces.getRealPath("/reports/instituicao.jasper");

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

            if(razaoInstituicao == null){
                parametros.put("razaosocial", "%%");
            }else{
                parametros.put("razaosocial", "%" + razaoInstituicao + "%");
            }
            if(cnpjInstituicao == null){
                parametros.put("cnpj", "%%");
            }else{
                parametros.put("cnpj", "%"+ cnpjInstituicao + "%");
            }

            Connection conexao = HibernateUtil.getConexao();

            JasperPrint relatorio = JasperFillManager.fillReport(caminho, parametros, conexao);
            JasperPrintManager.printReport(relatorio, true);

            Messages.addGlobalInfo("Relatório Gerado com sucesso!");

        } catch (JRException erro) {
            Messages.addGlobalError("Ocorreu um erro ao tentar imprimir a instituição!");           
            erro.printStackTrace();
            Messages.addGlobalError(erro.getMessage());
        }
    }

Console:

net.sf.jasperreports.engine.Jrexception: Error Printing report. at net.sf.jasperreports.engine.print.JRPrinterAWT.printPages(Jrprinterawt.java:214) at net.sf.jasperreports.engine.Jasperprintmanager.print(Jasperprintmanager.java:242) at net.sf.jasperreports.engine.Jasperprintmanager.print(Jasperprintmanager.java:129) at net.sf.jasperreports.engine.Jasperprintmanager.printReport(Jasperprintmanager.java:326) at br.pro.sispro.migreja.bean.InstituicaoBean.print(Institutcaobean.java:210) 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:497) 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.UIData.broadcast(Uidata.java:1108) 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:230) at org.apache.Catalina.core.Applicationfilterchain.doFilter(Applicationfilterchain.java:165) at org.primefaces.webapp.filter.Fileuploadfilter.doFilter(Fileuploadfilter.java:78) at org.apache.Catalina.core.Applicationfilterchain.internalDoFilter(Applicationfilterchain.java:192) at org.apache.Catalina.core.Applicationfilterchain.doFilter(Applicationfilterchain.java:165) at org.apache.Tomcat.websocket.server.WsFilter.doFilter(Wsfilter.java:52) at org.apache.Catalina.core.Applicationfilterchain.internalDoFilter(Applicationfilterchain.java:192) at org.apache.Catalina.core.Applicationfilterchain.doFilter(Applicationfilterchain.java:165) at org.apache.Catalina.core.Standardwrappervalve.invoke(Standardwrappervalve.java:198) at org.apache.Catalina.core.Standardcontextvalve.invoke(Standardcontextvalve.java:108) at org.apache.Catalina.authenticator.Authenticatorbase.invoke(Authenticatorbase.java:522) at org.apache.Catalina.core.Standardhostvalve.invoke(Standardhostvalve.java:140) at org.apache.Catalina.valves.Errorreportvalve.invoke(Errorreportvalve.java:79) at org.apache.Catalina.valves.Abstractaccesslogvalve.invoke(Abstractaccesslogvalve.java:620) at org.apache.Catalina.core.Standardenginevalve.invoke(Standardenginevalve.java:87) at org.apache.Catalina.connector.Coyoteadapter.service(Coyoteadapter.java:349) at org.apache.Coyote.ajp.Ajpprocessor.service(Ajpprocessor.java:780) at org.apache.Coyote.AbstractProcessorLight.process(Abstractprocessorlight.java:66) at org.apache.Coyote.Abstractprotocol$Connectionhandler.process(Abstractprotocol.java:785) at org.apache.Tomcat.util.net.Nioendpoint$Socketprocessor.doRun(Nioendpoint.java:1425) 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:745) Caused by: java.awt.Headlessexception at sun.print.Psprinterjob.printDialog(Psprinterjob.java:433) at net.sf.jasperreports.engine.print.JRPrinterAWT.printPages(Jrprinterawt.java:198) ... 46 more

  • The error does not clarify much. You have already tried to change the path?

No answers

Browser other questions tagged

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