Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
548 views
in Technique[技术] by (71.8m points)

java - NoClassDefFoundError: org/apache/commons/logging/LogFactory

I'm new in JasperReports and I want to integrate a JasperReports into my Java program, so when I click print button the program will show the report. But I get a NoClassDefFoundError when I click the button.

Code

JButton btnReport= new JButton("Report");
btnReport.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent arg0) { 
        try{
            String fileName= "src/learnReport/Leaf_Grey.jasper";
            Connection con = connect.getConnect();
            File file = new File(NameFile);
            JasperReport jasperReport = (JasperReport) JRLoader.loadObject(file);
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null,con);
            JasperViewer.viewReport(jasperPrint,false);
        } catch(Exception ex){
            System.out.println(ex);
        }
    }   
});

Runtime error

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 learnReport.Learning$6.actionPerformed(Learning.java:195)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have missed the jar file "org-apache-commons-logging.jar". Load this jar into your project. The Issue going to be resolved.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...