异常javafx应用程序线程

时间:2016-02-22 05:46:45

标签: java jasper-reports

在我的javafx应用程序中,我使用jasper-report工具创建报告。应用程序从我的intellij ide运行正常,但每当我尝试从我的jar文件运行它时,它给我的异常!!!

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/drawer_layout"

    >
    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >

<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:orientation="vertical"
            >



            <include
                android:id="@+id/app_bar"
                layout="@layout/app_bar"
                android:layout_height="wrap_content"
                android:layout_width="match_parent"
                />

<TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Product of the day"
                android:textSize="25sp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="10dp"
                android:textColor="#000"/>

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/rvProductOfTheDay"
                >

            </android.support.v7.widget.RecyclerView>

</LinearLayout>


    </ScrollView>

    <fragment
        android:id="@+id/fragment_navigation_drawer"
        android:layout_width="280dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        app:layout="@layout/fragment_navigation_drawer"
        android:name="com.tontosworld.tontosworld.NavigationDrawerFragment">

    </fragment>

</android.support.v4.widget.DrawerLayout>

在getSupplierListReport()方法中给我这个例外吗?如何解决我目前的这个问题?

日志:

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();
        }


    }

}

更新

添加throwable后

.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" 

以及日志:

 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();

        }

0 个答案:

没有答案