java NoClassDefFoundError: org/apache/commons/logging/LogFactory
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25376089/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NoClassDefFoundError: org/apache/commons/logging/LogFactory
提问by buncis
I'm new in JasperReportsand I want to integrate a JasperReportsinto my Java program, so when I click print button the program will show the report. But I get a NoClassDefFoundErrorwhen I click the button.
我是JasperReports 的新手,我想将JasperReports集成到我的 Java 程序中,因此当我单击打印按钮时,程序将显示报告。但是当我点击按钮时,我得到了一个NoClassDefFoundError。
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.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)
回答by N.L.N.Rao
You have missed the jar file "org-apache-commons-logging.jar". Load this jar into your project. The Issue going to be resolved.
您错过了 jar 文件“org-apache-commons-logging.jar”。将此 jar 加载到您的项目中。该问题将得到解决。