Execution error Jasperreport

Asked

Viewed 490 times

3

I have a problem with Jasperreport, I am developing an application for study, where I have a frontend that connects with a db (sqlserver) for registration, queries and reports. In the report part, when I will execute, it gives the following error:

Exception in thread "AWT-Eventqueue-0" java.lang.Noclassdeffounderror: org/apache/Commons/digester/Digester at convenios.reporterios.Telamovimentoconvenio.jButton1ActionPerformed(Telamovimentoconvenio.java:103) at convenios.reporterios.Telamovimentoconvenio.access$000(Telamovimentoconvenio.java:26) at convenios.reporterios.Telamovimentoconvenio$1.actionPerformed(Telamovimentoconvenio.java:49)

The code I’m 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 am using netbeans 8.1, with all the libraries added to 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 couldn’t find an easy-to-use example of the new 6.x jasperReport with japerstudio 6.x using netbean 8.1 only found examples of use with much older 4.x versions and with eclipse.

I managed to make it work I downloaded version 6.0.0 + joda-time-2.9.4 put everything that was in the lib in the libraries, 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, as I know which libs I should add?

everything working now added Jasperviewer.viewReport(jasperPrint);

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

  • NoClassDefFoundError occurs when one of the classes used is not located by the JVM. It may be an import error in classpath or you may have really forgotten to import the lib from the class to your classpath.

  • Hello thanks, also think it is a lib import problem. but this confusing which I should really import. here http://community.jaspersoft.com/wiki/jasperreports-library-requirements says one thing, but in other forums it says to import also those that are in: jasperreports-6.3.0-project jasperreports-6.3.0 lib only that there is nothing in this folder

  • Apparently the problem is not the impots but the classpath, see if it is loading Commons-digester.jar and also check Commons-beanutils.jar, Commons-Collections.jar and Commons-logging.jar.

No answers

Browser other questions tagged

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