In my javafx application i am using jasper-report tool for creating reports. The application runs ok from my intellij ide but whenever i am trying to run it from my jar file its giving me that exception!!!
public class ReportController extends BaseController {
Connection connection = null;
private JasperReportBuilder report;
Session session;
SessionFactory factory;
StyleBuilder boldStyle, boldCenteredStyle, columnTitleStyle, reportTitle;
public Button report1, crossButton;
public DatePicker from, to;
private double total;
@Override
public void initialize(URL location, ResourceBundle resources) {
super.initialize(location, resources);
BasicConfigurator.configure();
this.factory = new Configuration().configure().buildSessionFactory();
this.session = factory.openSession();
boldStyle = DynamicReports.stl.style().bold();
boldCenteredStyle = DynamicReports.stl.style(boldStyle).setPadding(5)
.setHorizontalAlignment(HorizontalAlignment.CENTER);
columnTitleStyle = DynamicReports.stl.style(boldCenteredStyle)
.setBorder(DynamicReports.stl.pen1Point())
.setBackgroundColor(Color.LIGHT_GRAY);
reportTitle = DynamicReports.stl.style(boldStyle).setPadding(30);
// initializing the datepicker values
initDatePicker();
session.doWork(new Work() {
@Override
public void execute(Connection c) throws SQLException {
connection = c;
}
});
report1.setOnAction(event -> {
getSupplierListReport();
}
);
}
private void initDatePicker() {
from.setValue(LocalDate.now());
final Callback<DatePicker, DateCell> dayCellFactory =
new Callback<DatePicker, DateCell>() {
@Override
public DateCell call(final DatePicker datePicker) {
return new DateCell() {
@Override
public void updateItem(LocalDate item, boolean empty) {
super.updateItem(item, empty);
if (item.isBefore(
from.getValue().plusDays(1))
) {
setDisable(true);
setStyle("-fx-background-color: #ffc0cb;");
}
long p = ChronoUnit.DAYS.between(
from.getValue(), item
);
setTooltip(new Tooltip(
"Report of " + p + " days")
);
}
};
}
};
to.setDayCellFactory(dayCellFactory);
}
//Giving error in this method
public void getSupplierListReport() {
report = DynamicReports.report();
try {
//show the report
report
.columns(
Columns.reportRowNumberColumn("No"),
Columns.column("First Name", "f_name", DataTypes.stringType()),
Columns.column("Last Name", "l_name", DataTypes.stringType()),
Columns.column("Email", "email", DataTypes.stringType())
)
.title(//title of the report
Components.text("Supplier List Report")
.setHorizontalAlignment(HorizontalAlignment.CENTER).setStyle(boldCenteredStyle))
.pageFooter(Components.pageXofY().setStyle(boldCenteredStyle))//show page number on the page footer
.highlightDetailEvenRows()
.setColumnTitleStyle(columnTitleStyle)
.setDataSource("SELECT f_name, l_name, email FROM suppliers where is_deleted = 0", connection)
.show();
//export the report to a pdf file
report.toPdf(new FileOutputStream("d:/supplier_list_report.pdf"));
} catch (DRException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
Giving me this exception in getSupplierListReport() method?? How to solve this problem on my current situation??
log:
.JasperSystemFontExtensionsRegistryFactory for property net.sf.jasperreports.extension.registry.factory.system.font.families
DEBUG DefaultExtensionsRegistry - Instantiating extensions registry for system.font.families using factory class net.sf.dynamicreports.jasper.base.JasperSystemFontExtensionsRegistryFactory
8578 [JavaFX Application Thread] DEBUG net.sf.jasperreports.extensions.DefaultExtensionsRegistry - Instantiating extensions registry for system.font.families using factory class net.sf.dynamicreports.jasper.base.JasperSystemFontExtensionsRegistryFactory
Exception in thread "JavaFX Application Thread"
Update:
after adding throwable
public void getSupplierListReport() {
report = DynamicReports.report();
try {
//show the report
report
.columns(
Columns.reportRowNumberColumn("No"),
Columns.column("First Name", "f_name", DataTypes.stringType()),
Columns.column("Last Name", "l_name", DataTypes.stringType()),
Columns.column("Email", "email", DataTypes.stringType())
)
.title(//title of the report
Components.text("Supplier List Report")
.setHorizontalAlignment(HorizontalAlignment.CENTER).setStyle(boldCenteredStyle))
.pageFooter(Components.pageXofY().setStyle(boldCenteredStyle))//show page number on the page footer
.highlightDetailEvenRows()
.setColumnTitleStyle(columnTitleStyle)
.setDataSource("SELECT f_name, l_name, email FROM suppliers where is_deleted = 0", connection)
.show();
//export the report to a pdf file
report.toPdf(new FileOutputStream("D:/supplier_list_report.pdf"));
}catch (Throwable e)
{
System.out.println("caught");
e.printStackTrace();
}
and also the log:
.DefaultExtensionsRegistry - Instantiating registry of type net.sf.dynamicreports.jasper.base.JasperSystemFontExtensionsRegistryFactory for property net.sf.jasperreports.extension.registry.factory.system.font.families
DEBUG DefaultExtensionsRegistry - Instantiating extensions registry for system.font.families using factory class net.sf.dynamicreports.jasper.base.JasperSystemFontExtensionsRegistryFactory
5543 [JavaFX Application Thread] DEBUG net.sf.jasperreports.extensions.DefaultExtensionsRegistry - Instantiating extensions registry for system.font.families using factory class net.sf.dynamicreports.jasper.base.JasperSystemFontExtensionsRegistryFactory
caught
Exception in thread "JavaFX Application Thread"