A problem in using JasperReports
.
I created a class to generate the reports, from some parameters. It inside Eclipse generates normally, but when I export WAR
and put it into production, it does nothing.
At first, I noticed that there was a detail - he could not find the file by using% 20 instead of the spaces in the report path, so I noticed in the Tomcat log, which had given FileNotFoundException
. So I used URLDecoder.decode
to resolve this, and it no longer returns FileNotFoundException
, but it still does not generate the report outside Eclipse.
Has anyone experienced anything like this?
public void imprimir(String arquivo, String nmTitulo,String nmParams, String nmParamsSegunda, List<?> dados) throws Exception{
JasperReport report = null;
try{
String caminhoRelatorio = this.getPathToReportPackage() + arquivo+".jrxml";
System.out.println("porCentoVinte:"+caminhoRelatorio);
caminhoRelatorio=URLDecoder.decode(caminhoRelatorio,"UTF-8");
System.out.println("porCentoVinte:"+caminhoRelatorio);
report = JasperCompileManager.compileReport(caminhoRelatorio);
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
VsecUsuario usr = (VsecUsuario) session.getAttribute("usuarioLogado");
String nmUsuario = usr.getNmUsuario();
String nmEmpresa = new Fncts().nmEmpresa();
Map relParams = new HashMap();
relParams.put("pNmTitulo", nmTitulo);
relParams.put("pNmEmpresa", nmEmpresa);
relParams.put("pNmRelParam", nmParams);
relParams.put("pNmRelParamSegunda", nmParamsSegunda);
relParams.put("pUsuarioSistema", nmUsuario);
JasperPrint pronto = JasperFillManager.fillReport(report, relParams, new JRBeanCollectionDataSource(dados));
JasperViewer viewer = new JasperViewer( pronto , false );
viewer.setVisible(true);
}catch(Exception e){
new Fncts().aviso(e.getMessage());
}
}
Andhere'sthelog
porCentoVinte:/D:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/SGC/WEB-INF/classes/br/com/virtus/jasper/reembolso.jrxmlporCentoVinte:/D:/ProgramFiles/ApacheSoftwareFoundation/Tomcat6.0/webapps/SGC/WEB-INF/classes/br/com/virtus/jasper/reembolso.jrxmlporCentoVinte:D:\Program%20Files\Apache%20Software%20Foundation\Tomcat%206.0\webapps\SGC\WEB-INF\classes\br\com\virtus\jasper\extratocartao.jrxmlporCentoVinte:D:\ProgramFiles\ApacheSoftwareFoundation\Tomcat6.0\webapps\SGC\WEB-INF\classes\br\com\virtus\jasper\extratocartao.jrxml[ELFinest]:jpa:2015-05-1416:21:12.003--ServerSession(14536956)--Thread(Thread[Finalizer,8,system])--BeginundeployingPersistenceUnitSGCProjectJPA;sessionfile:/D:/ProgramFiles/ApacheSoftwareFoundation/Tomcat6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA;stateDeployed;factoryCount6[ELFinest]:jpa:2015-05-1416:21:12.003--ServerSession(14536956)--Thread(Thread[Finalizer,8,system])--EndundeployingPersistenceUnitSGCProjectJPA;sessionfile:/D:/ProgramFiles/ApacheSoftwareFoundation/Tomcat6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA;stateDeployed;factoryCount5[ELFinest]:jpa:2015-05-1416:21:12.003--ServerSession(14536956)--Thread(Thread[Finalizer,8,system])--BeginundeployingPersistenceUnitSGCProjectJPA;sessionfile:/D:/ProgramFiles/ApacheSoftwareFoundation/Tomcat6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA;stateDeployed;factoryCount5[ELFinest]:jpa:2015-05-1416:21:12.003--ServerSession(14536956)--Thread(Thread[Finalizer,8,system])--EndundeployingPersistenceUnitSGCProjectJPA;sessionfile:/D:/ProgramFiles/ApacheSoftwareFoundation/Tomcat6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA;stateDeployed;factoryCount4[ELFinest]:jpa:2015-05-1416:21:12.003--ServerSession(14536956)--Thread(Thread[Finalizer,8,system])--BeginundeployingPersistenceUnitSGCProjectJPA;sessionfile:/D:/ProgramFiles/ApacheSoftwareFoundation/Tomcat6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA;stateDeployed;factoryCount4[ELFinest]:jpa:2015-05-1416:21:12.003--ServerSession(14536956)--Thread(Thread[Finalizer,8,system])--EndundeployingPersistenceUnitSGCProjectJPA;sessionfile:/D:/ProgramFiles/ApacheSoftwareFoundation/Tomcat6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA;stateDeployed;factoryCount3[ELFinest]:jpa:2015-05-1416:21:13.581--ServerSession(14536956)--Thread(Thread[http-8081-7,5,main])--BeginpredeployingPersistenceUnitSGCProjectJPA;sessionfile:/D:/ProgramFiles/ApacheSoftwareFoundation/Tomcat6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA;stateDeployed;factoryCount3[ELFinest]:jpa:2015-05-1416:21:13.581--ServerSession(14536956)--Thread(Thread[http-8081-7,5,main])--EndpredeployingPersistenceUnitSGCProjectJPA;sessionfile:/D:/ProgramFiles/ApacheSoftwareFoundation/Tomcat6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA;stateDeployed;factoryCount4[ELFinest]:jpa:2015-05-1416:21:13.581--ServerSession(14536956)--Thread(Thread[http-8081-7,5,main])--BegindeployingPersistenceUnitSGCProjectJPA;sessionfile:/D:/ProgramFiles/ApacheSoftwareFoundation/Tomcat6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA;stateDeployed;factoryCount4[ELFinest]:jpa:2015-05-1416:21:13.581--ServerSession(14536956)--Thread(Thread[http-8081-7,5,main])--EnddeployingPersistenceUnitSGCProjectJPA;sessionfile:/D:/ProgramFiles/ApacheSoftwareFoundation/Tomcat6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA;stateDeployed;factoryCount4----TESTEDEBUSCAPORCÓDIGO----[ELFiner]:connection:2015-05-1416:21:13.581--ServerSession(14536956)--Thread(Thread[http-8081-7,5,main])--clientacquired:8519566[ELFiner]:transaction:2015-05-1416:21:13.581--ClientSession(8519566)--Thread(Thread[http-8081-7,5,main])--acquireunitofwork:11594463[ELFinest]:query:2015-05-1416:21:13.581--UnitOfWork(11594463)--Thread(Thread[http-8081-7,5,main])--ExecutequeryReadObjectQuery(name="readFiliai" referenceClass=Filiai sql="SELECT CD_FILIAL, CD_ARQ_ENVIO, CD_ARQ_RETORNO, CD_CEP_ENDERECO_FILIAL, CD_CNPJ, CD_DDD_FILIAL, CD_FAX_FILIAL, CD_IE_FILIAL, CD_IM_FILIAL, CD_LOCAL_COBRANCA, CD_NUMERO_ENDERECO_FILIAL, CD_OCORR_DEPOSITO_CHEQUE, CD_SERIE_NOTA_FISCAL, CD_TELEFONE_FILIAL, CD_ULTIMA_NF_FILIAL, CD_ULTIMO_PEDIDO_COMPRA, DONE, DTL, NM_BAIRRO_ENDERECO_FILIAL, NM_CIDADE_FILIAL, NM_COMPL_ENDERECO_FILIAL, NM_ENDERECO_FILIAL, NM_FILIAL, PC_ISS, PC_MAXIMO_FRETE_FILIAL, PC_MULTA_FILIAL, QT_DIAS_CARENCIA_FILIAL, SG_UF FROM FILIAIS WHERE (CD_FILIAL = ?)")
[EL Finest]: transaction: 2015-05-14 16:21:13.581--UnitOfWork(11594463)--Thread(Thread[http-8081-7,5,main])--Register the existing object br.com.virtus.sgc.model.Filiai@87208fa3
[EL Finest]: jpa: 2015-05-14 16:21:14.19--ServerSession(14536956)--Thread(Thread[Finalizer,8,system])--Begin undeploying Persistence Unit SGCProjectJPA; session file:/D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA; state Deployed; factoryCount 4
[EL Finest]: jpa: 2015-05-14 16:21:14.19--ServerSession(14536956)--Thread(Thread[Finalizer,8,system])--End undeploying Persistence Unit SGCProjectJPA; session file:/D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/SGC/WEB-INF/lib/SGCProjectJPA.jar_SGCProjectJPA; state Deployed; factoryCount 3