Why does the following statement run on Windows and not linux?
JasperPrintManager.printReport(relatorio, true);
In the window open the printer dialog, but in Linux show the next error:
net.sf.jasperreports.engine.JRException: Report printing 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.pro.sispro.migreja.bean.InstituicaoBean.print (InstituicaoBean.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