Reputation: 109
What I'm trying to do is to create a simple report in jasper iReport and view it in Javafx file.
When I try to open the file it throws a error at this line:
JasperDesign jasperdesign = JRXmlLoader.load("C:\\Users\\chirag\\Documents\\NetBeansProjects\\User_management_application\\src\\reports\\UserLogs.jrxml");
The report path is copied from the properties of UserLogs.jrxml
file
The method snippet where I am trying to load the report:
try {
JasperReport jasperReport;
JasperPrint jasperPrint;
String qry = "SELECT * FROM user_master a inner join user_log_management b on a.User_Master_Id = b.userMaster_User_Master_Id where b.Entry_Date like '" + date1.getValue() + "%'";
JRDesignQuery newQuer = new JRDesignQuery();
newQuer.setText(qry);
JasperDesign jasperdesign = JRXmlLoader.load("C:\\Users\\chirag\\Documents\\NetBeansProjects\\User_management_application\\src\\reports\\UserLogs.jrxml");
jasperdesign.setQuery(newQuer);
jasperReport = JasperCompileManager.compileReport(jasperdesign);
jasperPrint = JasperFillManager.fillReport(jasperReport, null, MySqlConnection.conn());
boolean isLinuxSelected = radiopdf.isSelected();
if (isLinuxSelected) {
JasperExportManager.exportReportToPdfFile(jasperPrint, "reports//UserLogs.pdf");
String pdflocation = "reports//UserLogs.pdf";
try {
if (Desktop.isDesktopSupported()) {
try {
File myFile = new File(pdflocation);
Desktop.getDesktop().open(myFile);
} catch (Exception ex) {
}
}
} catch (Exception ep) {
Alert alerts = new Alert(Alert.AlertType.ERROR);
alerts.setContentText("Sorry no Records to be previewed.");
alerts.show();
}
} else {
JDialog jviewer = new JDialog();
JRViewer aViewer = new JRViewer(jasperPrint);
jviewer.setTitle("Report Preview");
jviewer.setModal(true);
jviewer.getContentPane().add(aViewer);
jviewer.pack();
java.awt.Dimension diadim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
jviewer.setSize(diadim.width, diadim.height);
jviewer.requestFocus();
jviewer.show();
jviewer.setAlwaysOnTop(true);
}
MySqlConnection.closeConnection();
System.gc();
} catch (JRException ex) {
Logger.getLogger(ReportsController.class.getName()).log(Level.SEVERE, null, ex);
}
The error message:
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1765)
... 50 more
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
at ControllerPack.ReportsController.generate(ReportsController.java:126)
... 60 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.digester.Digester
I am unable to figure out the error please help me.
Upvotes: 0
Views: 990
Reputation: 96039
The base cause is
Caused by: java.lang.ClassNotFoundException: org.apache.commons.digester.Digester
Thus, it looks like you don't provide the required dependencies for JasperReports. Add commons-digester-*.jar
in the version required by your JR version (and probably other missing libraries).
Upvotes: 1