1

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" 
Alex K
  • 22,315
  • 19
  • 108
  • 236
Fay007
  • 2,707
  • 3
  • 28
  • 58
  • check log in the question @shmosel – Fay007 Feb 22 '16 at 05:53
  • Your log doesn't show an exception at all (it says `DEBUG`...). This or you have not pasted the relevant part. – fge Feb 22 '16 at 06:16
  • its says just it!! nothing else, so i couldn't figure out whats the problem @fge – Fay007 Feb 22 '16 at 06:32
  • You are probably having a font-extension problem (when exporting to pdf font can not be found, the duplicated probably is this http://stackoverflow.com/questions/3811908/jvm-fonts-and-jasperreports, but there are no good answers there (installing font on server or disabling is work arounds), the correct way is to generate font-extensions see this http://stackoverflow.com/questions/33940126/how-can-i-display-%C2%A3%E2%84%A6%E2%82%AC%CE%B1%CF%80%E2%85%94-in-jasperserver-pdf-using-ireport – Petter Friberg Feb 22 '16 at 08:16
  • but the thing is it is working perfectly when i am running the application but not working from the jar file!! what could be the reason?? @PetterFriberg – Fay007 Feb 22 '16 at 08:41
  • Probably class path, jvm environment, if you like to export to pdf you **need to** handle font-extensions. I have passed an answer on the suggested duplicate (since I did not like the present ones) http://stackoverflow.com/questions/3811908/jvm-fonts-and-jasperreports/35549391#35549391, check it out to understand – Petter Friberg Feb 22 '16 at 09:05
  • However I can not be sure that this is the exception since I do not see it. I suggest you catch (Throwable e){e.printStackTrace()} so we see the true error.... – Petter Friberg Feb 22 '16 at 09:08
  • It can be another error as not having access to write to file!! – Petter Friberg Feb 22 '16 at 09:09
  • i used catch (Throwable e){e.printStackTrace();} in my try block yet no luck!!! nothing showed except this one!!! @PetterFriberg – Fay007 Feb 22 '16 at 10:27
  • besides i don't see any other section with problem @PetterFriberg – Fay007 Feb 22 '16 at 11:28
  • hmm, you have an error some where, just try{}catch it all and you will find it... – Petter Friberg Feb 22 '16 at 11:29
  • btw i just did debugging the code and found out that it shows that exception on line report.show() @PetterFriberg – Fay007 Feb 22 '16 at 12:43
  • 1
    a catch(Throwable e) will tell you the exception... – Petter Friberg Feb 22 '16 at 12:50
  • check the update!! its still not showing me anything solid!!! @PetterFriberg – Fay007 Feb 22 '16 at 12:59
  • How do you run it?, you are able to see system.out correct? – Petter Friberg Feb 22 '16 at 13:07
  • i am running my jar file from intellij ide after building the project as a jar file @PetterFriberg – Fay007 Feb 22 '16 at 13:13
  • and doing this you see the System.out.println?. e.printStackTrace().... I guess not or your error is not there.. – Petter Friberg Feb 22 '16 at 13:49
  • have u ever tried to run the jar file from intellij ide...!!! it does show system.out.println!!! and about error its throwing from the show method which is not in my project... i have added that jar as a library(which contains the show method) – Fay007 Feb 23 '16 at 04:54

0 Answers0