Come correggere NoClassDefFoundError org / apache / commons / logging / LogFactory [duplicate]
Oct 17 2020
Di seguito è riportato il codice che sto cercando di utilizzare per connettermi a un database e visualizzare i report in 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());
}
}
Ho ricevuto il seguente errore:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
Risposte
1 thetechnician94 Oct 17 2020 at 02:39
Non so molto di Jasper, ma presumo che abbia una dipendenza da Apache Commons Log Framework, quindi probabilmente dovrai aggiungere Apache Commons Logging al tuo classpath.
Vedere: https://commons.apache.org/proper/commons-logging/guide.html