如何修复 NoClassDefFoundError org/apache/commons/logging/LogFactory

huangapple go评论74阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年10月17日 03:35:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/64395344.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定