英文:
How to fix NoClassDefFoundError org/apache/commons/logging/LogFactory
问题
以下是我尝试使用的代码,连接到数据库并在JasperViewer中查看报表。
private void jButton1ActionPerformed(ActionEvent evt) {
try {
String dbURL = "jdbc:oracle:thin:@localhost:1521:xe";
String username = "user";
String password = "pwd";
Connection con = DriverManager.getConnection(dbURL, username, password);
String reportPath = "C:\\path\\extention.jrxml";
JasperReport jr = JasperCompileManager.compileReport(reportPath);
JasperPrint jp = JasperFillManager.fillReport(jr, null, con);
JasperViewer.viewReport(jp);
con.close();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
我得到了以下错误:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
英文:
Below is the code I am trying to use to connect to a database and view reports in the JasperViewer.
private void jButton1ActionPerformed(ActionEvent evt) {
try {
String dbURL = "jdbc:oracle:thin:@localhost:1521:xe";
String username = "user";
String password = "pwd";
Connection con = DriverManager.getConnection(dbURL, username, password);
String reportPath = "C:\\path\\extention.jrxml";
JasperReport jr = JasperCompileManager.compileReport(reportPath);
JasperPrint jp = JasperFillManager.fillReport(jr, null, con);
JasperViewer.viewReport(jp);
con.close();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
I got the following error:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
答案1
得分: 1
我不太了解Jasper,但我假设它依赖于Apache Commons Log Framework,所以你可能需要将Apache Commons Logging添加到你的类路径中。
参见:https://commons.apache.org/proper/commons-logging/guide.html
英文:
I don't know much about Jasper, but I assume it has a dependency on Apache Commons Log Framework, so you probably need to add Apache Commons Logging to your classpath.
See: https://commons.apache.org/proper/commons-logging/guide.html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论