NoClassDefFoundError:org / apache / commons / logging / LogFactory [英] NoClassDefFoundError: org/apache/commons/logging/LogFactory
本文介绍了NoClassDefFoundError:org / apache / commons / logging / LogFactory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 JasperReports 的新手,我想将 JasperReports 集成到我的Java程序中,
所以当我点击打印按钮时,程序会显示报告。但是当我点击按钮时,我得到一个 NoClassDefFoundError 。
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.
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)
推荐答案
您错过了jar文件org-apache-commons-logging.jar。将此jar加载到您的项目中。问题将得到解决。
You have missed the jar file "org-apache-commons-logging.jar". Load this jar into your project. The Issue going to be resolved.
这篇关于NoClassDefFoundError:org / apache / commons / logging / LogFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文