JasperReport execution error

3

I'm having a problem with JasperReport , I'm developing an application for study, where I have a frontend that connects to a db (sqlserver) for registers, queries and reports. In the report part, when I go to run, it gives the following error:

  

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:   org / apache / commons / digester / Digester at   conventions.relations.TableMovementConvention.jButton1ActionPerformed (ScreenMovementConvention.java:103)     at   convenios.relatorios.TelaMovimentoConvenio.access $ 000 (TelaMovimentoConvenio.java:26)     at   conventions.relations.TelMovementConvention $ 1.actionPerformed (ScreenMoveConvention.java:49)

The code I am using is:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package convenios.relatorios;

import convenios.modelo.Cliente;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JasperDesign;
import net.sf.jasperreports.engine.xml.JRXmlLoader;

/**
 *
 * @author Roberto
 */
public class TelaMovimentoConvenio extends javax.swing.JInternalFrame {

    /**
     * Creates new form TelaMovimentoConvenio
     */
    public TelaMovimentoConvenio() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jButton1 = new javax.swing.JButton();

        jButton1.setText("jButton1");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(446, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(52, 52, 52))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jButton1)
                .addContainerGap(47, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:

        InputStream inputStream = null;
        JasperPrint jasperPrint= null;
        MovimentoConvenioDataSource datasource = new MovimentoConvenioDataSource();


        for(int i = 0; i<=5; i++){

            Cliente cliente;
            cliente = new Cliente(i, "Nome "+i,"Endreco "+i);
            datasource.addAsistente(cliente);
           }
        try {
           inputStream = new FileInputStream ("src\convenios\relatorios\movConvenio.jrxml");

       } catch (FileNotFoundException ex) {
           JOptionPane.showMessageDialog(null,"Erro ao ler o relatório "+ex.getMessage());
        }

        try{
            JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
            JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
            jasperPrint = JasperFillManager.fillReport(jasperReport, null, datasource);
            JasperExportManager.exportReportToPdfFile(jasperPrint, "src\convenios\relatorios\reporte01.pdf");

        }catch (JRException e){
            JOptionPane.showMessageDialog(null,"Erro ao ler o relatório "+e.getMessage());
        }



    }                                        


    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    // End of variables declaration                   
}

I'm using netbeans 8.1, with the libraries all added in the project.

jasperreports-6.3.0, jasperreports-fonts-6.3.0, jasperreports-functions-6.3.0, jasperreports-javaflow-6.3.0 commons-beanutils-1.9.2, commons-collections4-4.1, commons-digester3-3.2, commons-logging-1.2 sqljdbc4

I have not found an easy-to-use example of jasperReport new 6.x with japerstudio 6.x using netbean 8.1 I only found examples of use with much older versions 4.x and with eclipse.

I was able to run it I downloaded the version 6.0.0 + joda-time-2.9.4 I put everything that was in the lib in the libraries, there are no more errors. now just give this warning

log4j: WARN No appenders could be found for logger (net.sf.jasperreports.engine.xml.JRXmlDigesterFactory). log4j: WARN Please initialize the log4j system properly.

The report is being generated but does not show the report: (

I have to really add all these libs to the project, how do I know which libs to add?

Everything working now I've added JasperViewer.viewReport (jasperPrint);

But only in version 6.0.0, where do I get the jasperReport 6.3.0 libs?

    
asked by anonymous 18.07.2016 / 16:03

1 answer

0

Apparently the problem is not the impots but the classpath, see if you are loading commons-digester.jar and also check commons-beanutils.jar, commons-collections.jar, and commons-logging.jar.

    
26.08.2016 / 17:55