Jump to content
JGD

Jaspersoft Studio (novo iReport) / JasperFillManager.fillReport

Recommended Posts

Olá,

Estou tentado gerar relatórios com o novo iReport (já que o java do projeto é java oito)
Baixer Jaspersoft Studio (novo iReport) e JasperReports Library em Jaspersoft Community...

no pacote notei ausência de alguns jar que existiam na versão antiga (como: common-beanutils, Commons-digester, itextpdf, etc)
nas estutura do pacote na há a pasta "lib"... apenas pasta "dist" com os jar: jasperreports-6.5.1, jasperreports-fonts-6.5.1 e jasperreports-javaflow-6.5.1..

Voltado.. Gerei o relatório no inteface Jaspersoft Studio...
Digo: fiz conexçao, testei e compilei (arquivos: .jasper e .jrxml) o relatório.

Certinho! Funcionou o relatórios com layout e dados..


Daí tente implementar no projeto java:

Botão:

    btnPrint1.addActionListener(new ActionListener() {  
                    public void actionPerformed(ActionEvent e) {  
                          try {  
                                  
                              Connection connection4 =  ConexaoUtil.getInstance().getConnection();  
                              HashMap param = new HashMap();  
                              JasperPrint jp = JasperFillManager.fillReport("src/MyiReport/MyReports/bin", param, connection4);  
                              // e tb assim: 
                              // JasperPrint jp = JasperFillManager.fillReport("C:\\pasta_1\\pasta_2\\src\\MyiReport\\relatorios\\lista_prod_1_A4.jasper", param, connection4);  
                              JasperViewer jw = new JasperViewer(jp);  
                              jw.setVisible(true);  
                          
                                  
                            } catch (JRException e1) {  
                                // TODO Auto-generated catch block  
                                e1.printStackTrace();  
                            } catch (ClassNotFoundException e1) {  
                                // TODO Auto-generated catch block  
                                e1.printStackTrace();  
                            } catch (SQLException e1) {  
                                // TODO Auto-generated catch block  
                                e1.printStackTrace();  
                            }  
                              
                          
                    }  
                });  

Dai deu erro: 

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory  
    at net.sf.jasperreports.engine.util.JRLoader.<clinit>(JRLoader.java:81)  
    at net.sf.jasperreports.engine.JRPropertiesUtil.loadProperties(JRPropertiesUtil.java:102)  
    at net.sf.jasperreports.engine.DefaultJasperReportsContext.initProperties(DefaultJasperReportsContext.java:108)  
    at net.sf.jasperreports.engine.DefaultJasperReportsContext.<init>(DefaultJasperReportsContext.java:85)  
    at net.sf.jasperreports.engine.DefaultJasperReportsContext.<clinit>(DefaultJasperReportsContext.java:68)  
    at net.sf.jasperreports.engine.JasperFillManager.getDefaultInstance(JasperFillManager.java:87)  
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:759)  
    at br.com.montebranco.fiscal01.FrmPrincipal$12.actionPerformed(FrmPrincipal.java:1258)  
    ....  

Então eu add os seguintes jar:

commons-digester-2.0
commons-collections-3.2.1
commons-beanutils-1.8.3
commons-digester-2.0
commons-logging-1.1.1
groovy-all-1.5.5
iText-5.0.4

 

Considerando alguma eventual dependência da antiga versão. Mas o erro persiste. 

 

Sou grato por qualquer ajuda  

 

 

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By Overtron8000
      Ola galera, estive fazendo um app simples de impressao de formulario usando o ireport mas não estou conseguindo passar os parametros do formulario para o documento jmxl ja tentei de toda forma mas simplesmente esta caindo no catch e saindo sem criar o arquivo.
      private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { HashMap parametros = new HashMap(); parametros.put("fornecedor", fornecedortF.getText()); parametros.put("ncontrato", ncontratoF.getText()); String caminhoRelJasper = "geradorcontrato/relatorio.jrxml"; InputStream fonte = this.getClass().getClassLoader().getResourceAsStream(caminhoRelJasper); try { JasperReport report = JasperCompileManager.compileReport(fonte); JasperPrint print = JasperFillManager.fillReport(report,parametros, new JREmptyDataSource()); JasperExportManager.exportReportToPdfFile(print,"teste.pdf"); System.out.println("imprimiu"); }catch(JRException e){ System.out.println("caiu no catch");} System.out.println("saiu"); } Dai era para esses parametros do map irem pro jxml nao estao indo, nem cria um novo pdf na pasta.
      link do projeto: https://github.com/regis404/Gerador-de-Contratos
    • By daniellecd
      Bom dia Pessoal! Tudo bem?
      Estou fazendo um relatório onde tenho duas consultas diferentes.
      A primeira -> é a consulta principal do relatório, que faz o cabeçalho de informações referente aos professores e turmas, e recebe parâmetros informados pelo usuário. Ao rodar, ela também alimenta dois parâmetros que criei nessa consulta principal, onde eles devem ser passados para serem utilizados na segunda consulta que é o Data Set: ListaAlunos.
      Segunda consulta -> Data set. Esse data set, criei para listar os registro dos alunos, mas este tem que receber da consulta principal os parâmetros por ela retornados.
      Pergunta:
      Como faço para passar os parâmetro da primeira consulta para serem usados na segunda consulta?
      Desde já agradeço imensamente pela ajuda!
    • By daniellecd
      Bom dia pessoal,
      Estou a desenvolver um relatório utilizando o iReport, mas deparei com um problema que não consigo resolver.
      Monto todo o relatório e coloco a tabela na sessão DETAIL. Faço o dataset, coloco o select, faço o preview do resultado do select, 32 registos, ok!
      Mas quando faço o preview do relatório, o mesmo repete a tabela na mesma quantidade de registros, o que faz com o que um relatório de 1 folha, tenha 32 folhas com a mesma tabela.
      Como faço para resolver?
      Poderiam me ajudar?
      Desde já agradeço imensamente
    • By danillo.sdd
      Não consigo fazer funcionar o o ireport com subreport para execução no php, através do PHPJasperXML....
       
      Só da erro de internal server error...
       
      (Quando o tiro o subreport funciona)
       
       
      Deve ser na configuração do subreport, mais ja tentei de tudo...
    • By gui_nastrini
      No sistema gerencial que estou trabalhando, gero em PDF um comprovante não fiscal para impressora térmica, feito no iReport, utilizando a biblioteca PHPJasperXML. Neste comprovante, quando se tem apenas um produto (uma linha) na aba Detail, os campos do Summary vem em branco. Quando se tem dois produtos ou mais (duas linhas ou mais) na aba Detail, os campos são preenchidos normalmente. No preview do programa iReport funciona perfeitamente, com um ou dois produtos.
       
      Segue o jrxml do relatório (somente o detail e o summary):
       
      <detail> <band height="25" splitType="Stretch"> <textField isStretchWithOverflow="true"> <reportElement x="0" y="0" width="186" height="12" uuid="e06c4bc6-e0f7-4e0e-8a7b-ab5ce1fd5e62"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement verticalAlignment="Middle"> <font size="7" isBold="false"/> <paragraph leftIndent="5"/> </textElement> <textFieldExpression><![CDATA[$F{descricao}]]></textFieldExpression> </textField> <textField pattern="#,##0.00;-#,##0.00"> <reportElement x="52" y="12" width="67" height="12" uuid="1d928a34-4972-4204-9612-9f0e8a6749d3"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="7"/> <paragraph rightIndent="5"/> </textElement> <textFieldExpression><![CDATA[$F{valor}]]></textFieldExpression> </textField> <textField pattern="#,##0.00;-#,##0.00"> <reportElement x="0" y="12" width="52" height="12" uuid="f6d30d04-d0fe-4dd3-a675-377ff6d2b473"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="7"/> <paragraph rightIndent="5"/> </textElement> <textFieldExpression><![CDATA[$F{quantidade}]]></textFieldExpression> </textField> <textField pattern="#,##0.00;-#,##0.00"> <reportElement x="119" y="12" width="67" height="12" uuid="0603e3b7-801d-49af-9a06-5d33023c5277"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement textAlignment="Center" verticalAlignment="Middle"> <font size="7"/> <paragraph rightIndent="5"/> </textElement> <textFieldExpression><![CDATA[$F{subtotal}]]></textFieldExpression> </textField> </band> </detail> <summary> <band height="203"> <staticText> <reportElement mode="Opaque" x="0" y="82" width="85" height="16" backcolor="#CCCCCC" uuid="6b173bab-525a-4da5-a564-723a8cbb1fbc"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement verticalAlignment="Middle"> <font size="7" isBold="true"/> <paragraph leftIndent="5"/> </textElement> <text><![CDATA[R$ TROCO:]]></text> </staticText> <staticText> <reportElement x="0" y="3" width="53" height="12" uuid="c99a6844-ca28-47c7-a022-80d2717bf547"/> <textElement textAlignment="Center" verticalAlignment="Bottom"> <font size="7"/> <paragraph leftIndent="5"/> </textElement> <text><![CDATA[Emissão:]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="0" y="66" width="85" height="16" backcolor="#CCCCCC" uuid="d0b8947e-8183-4a55-8b6d-f238bdac0404"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement verticalAlignment="Middle"> <font size="7" isBold="true"/> <paragraph leftIndent="5"/> </textElement> <text><![CDATA[R$ TOTAL REC.:]]></text> </staticText> <textField pattern="#,##0.00;-#,##0.00"> <reportElement isPrintRepeatedValues="false" x="85" y="82" width="101" height="16" uuid="a15e9cba-0f96-42be-8071-dbd7afecf73a"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement textAlignment="Right" verticalAlignment="Middle"> <font size="7"/> <paragraph rightIndent="5"/> </textElement> <textFieldExpression><![CDATA[$F{troco}]]></textFieldExpression> </textField> <textField pattern="#,##0.00;-#,##0.00"> <reportElement isPrintRepeatedValues="false" x="85" y="34" width="101" height="16" uuid="47411e66-b385-427c-825c-3be4e4abe45e"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement textAlignment="Right" verticalAlignment="Middle"> <font size="7"/> <paragraph rightIndent="5"/> </textElement> <textFieldExpression><![CDATA[$F{desconto}]]></textFieldExpression> </textField> <staticText> <reportElement mode="Opaque" x="0" y="34" width="85" height="16" backcolor="#CCCCCC" uuid="05f791f7-9e38-4ee2-b7db-8e1ec1d6275f"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement verticalAlignment="Middle"> <font size="7" isBold="true"/> <paragraph leftIndent="5"/> </textElement> <text><![CDATA[R$ DESCONTO:]]></text> </staticText> <staticText> <reportElement mode="Opaque" x="0" y="18" width="85" height="16" backcolor="#CCCCCC" uuid="3c260ede-9083-41f2-aa35-b2e044fc645a"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement verticalAlignment="Middle"> <font size="7" isBold="true"/> <paragraph leftIndent="5"/> </textElement> <text><![CDATA[R$ SUBTOTAL:]]></text> </staticText> <textField> <reportElement x="52" y="3" width="134" height="12" uuid="47291c92-c9d1-40ac-a8d8-82247f26f98b"/> <textElement verticalAlignment="Top"> <font size="7"/> <paragraph leftIndent="5"/> </textElement> <textFieldExpression><![CDATA[$F{hoje}]]></textFieldExpression> </textField> <textField pattern="#,##0.00;-#,##0.00"> <reportElement isPrintRepeatedValues="false" x="85" y="66" width="101" height="16" uuid="798cef8b-50c8-437b-af79-95526dbcd315"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement textAlignment="Right" verticalAlignment="Middle"> <font size="7"/> <paragraph rightIndent="5"/> </textElement> <textFieldExpression><![CDATA[$F{total_rec}]]></textFieldExpression> </textField> <textField pattern="#,##0.00;-#,##0.00"> <reportElement isPrintRepeatedValues="false" mode="Transparent" x="85" y="18" width="101" height="16" uuid="ac0e949b-93f4-4ded-a654-97230a33cb20"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement textAlignment="Right" verticalAlignment="Middle"> <font size="7" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false"/> <paragraph rightIndent="5"/> </textElement> <textFieldExpression><![CDATA[$F{total_prod}]]></textFieldExpression> </textField> <textField pattern="#,##0.00;-#,##0.00"> <reportElement isPrintRepeatedValues="false" x="85" y="50" width="101" height="16" uuid="98a37383-f178-4e9b-817a-66c3ebe183a5"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement textAlignment="Right" verticalAlignment="Middle"> <font size="7"/> <paragraph rightIndent="5"/> </textElement> <textFieldExpression><![CDATA[$F{total_venda}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true"> <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="0" y="102" width="186" height="98" isPrintWhenDetailOverflows="true" uuid="85f18504-1690-48ae-a11a-02a6b0ef4489"/> <box> <pen lineColor="#999999"/> <topPen lineColor="#999999"/> <leftPen lineColor="#999999"/> <bottomPen lineColor="#999999"/> <rightPen lineColor="#999999"/> </box> <textElement markup="none"> <font size="7" isPdfEmbedded="false"/> </textElement> <textFieldExpression><![CDATA[$F{pagamentos_venda}]]></textFieldExpression> </textField> <staticText> <reportElement mode="Opaque" x="0" y="50" width="85" height="16" backcolor="#CCCCCC" uuid="1fc6ac4f-3090-4de5-8fd6-7562b4058ecf"/> <box> <pen lineWidth="0.25" lineColor="#999999"/> <topPen lineWidth="0.25" lineColor="#999999"/> <leftPen lineWidth="0.25" lineColor="#999999"/> <bottomPen lineWidth="0.25" lineColor="#999999"/> <rightPen lineWidth="0.25" lineColor="#999999"/> </box> <textElement verticalAlignment="Middle"> <font size="7" isBold="true"/> <paragraph leftIndent="5"/> </textElement> <text><![CDATA[R$ TOTAL:]]></text> </staticText> <line> <reportElement x="0" y="0" width="186" height="1" uuid="e3ab1d85-d813-4fe6-ba0d-70c9bf390b79"/> </line> </band> </summary> Veja os resultados em PDF:
       
      1 - Com um produto:

       
      2 - Com dois produtos:

       
      Os valores já vem prontos do banco de dados MySQL, nada é alterado ou incrementado dentro do Summary. Já tentei com parameter e variable mas não deu certo.
       
      Alguém tem alguma ideia? Seria um problema no relatório ou alguma configuração de servidor?
       
      Obrigado desde já!
×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.