Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Factory is null
Factory is null [message #1796671] Wed, 17 October 2018 10:13
Yue Clemes is currently offline Yue ClemesFriend
Messages: 2
Registered: August 2015
Junior Member


Hi i'm new here and first sorry for my bad english.

Using project with Gradle

compile files('src/main/resources/lib/flute-1.3.jar') compile(group: 'org.eclipse.birt.runtime', name: 'org.eclipse.birt.runtime', version: '4.4.2') { exclude(group: 'org.milyn', module: 'flute') }


I got no problem when running local via void main method. But after compile project via

shadowJar { classifier = null version = version manifest { attributes 'Main-Class': 'io.vertx.core.Starter' attributes 'Main-Verticle': 'other.app.App' } mergeServiceFiles { include 'META-INF/services/io.vertx.core.spi.VerticleFactory' } }


i got null on

IReportEngineFactory factory = (IReportEngineFactory) Platform .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);


Trying to dig this problem around for a week, i still can't find a solution. Anyone got suggesstion? Tysm for reading.

My code on it:

    @Override
        public void generateUserInformationPdf(JsonObject payload) {

            try {

                LOGGER.info("Starting render User Information");

                /* begin get parameters */

                CommonRequest request = gson.fromJson(payload, CommonRequest.class);

                UserPdfPrint userInformation = gson.fromJson(request.getData(), UserPdfPrint.class);

                String p_username = userInformation.getUsername();
                String p_customername = userInformation.getCustomerName();
                String p_dob = userInformation.getDob();
                String p_license = userInformation.getLicense();
                String p_licensedate = userInformation.getLicenseDate();
                String p_licenseplace = userInformation.getLicensePlace();
                String p_sex = userInformation.getSex();
                String p_customerphone = userInformation.getCustomerPhone();
                String p_email = userInformation.getEmail();
                int p_licensetype = userInformation.getLicenseType();


                /* end get parameters section */

                /* load report design */
                String reportName = config.getReportUserInformation();
                IReportEngine engine = null;
                IReportRunnable design = null;

                URL url = null;
                url = new URL(config.getReportFontConfig());

                engineConfig = new EngineConfig();
                engineConfig.setEngineHome("ReportEngine");
                engineConfig.setLogConfig(null, Level.FINE);
                engineConfig.setFontConfig(url);

                Platform.startup(engineConfig);

                IReportEngineFactory factory = (IReportEngineFactory) Platform
                        .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);

                engine = factory.createReportEngine(engineConfig);

                design = engine
                        .openReportDesign(config.getReportTemplatePath()
                                + "/" + reportName); // report

                /* end load report design */

                /* begin render report */
                IRunAndRenderTask task = null;
                PDFRenderOption renderContext = null;
                HashMap contextMap = null;

                task = engine.createRunAndRenderTask(design);
                renderContext = new PDFRenderOption();
                contextMap = new HashMap();
                contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,
                        renderContext);
                contextMap.put("OdaJDBCDriverPassInConnection", config.getDbConnection());
                task.setAppContext(contextMap);

                task.setParameterValue("p_username", p_username);
                task.setParameterValue("p_customername", p_customername);
                task.setParameterValue("p_dob", p_dob);
                task.setParameterValue("p_license", p_license);
                task.setParameterValue("p_licensedate", p_licensedate);
                task.setParameterValue("p_licenseplace", p_licenseplace);
                task.setParameterValue("p_sex", p_sex);
                task.setParameterValue("p_licensetype", String.valueOf(p_licensetype));
                task.setParameterValue("p_email", p_email);
                task.setParameterValue("p_customerphone", p_customerphone);
                task.validateParameters();

                String random = Generator.generateRandomNumber();

                String today = DateTimes.getCurrentDate().toString();

                String parsedToDate = DateTimes.parseDate(today, "EE MMM dd HH:mm:ss z yyyy").toString();

                String toDateString = DateTimes.parseDate(parsedToDate, "dd-MM-yyyy-hh-mm-ss").toString();

                String reportNameInFolder = "UserInformation" + toDateString
                        + random;

                String outPutFile = config.getReportOutputPath() + reportNameInFolder + ".pdf";

                PDFRenderOption options = null;
                options = new PDFRenderOption();
                options.setOutputFormat("pdf");
                options.setOutputFileName(outPutFile);

                task.setRenderOption(options);
                task.run();

                System.out.println("All went well. Closing program!");

                /* end render report */

                engine.destroy();
                task.close();
                options.closeOutputStreamOnExit(true);

                mqAdapter.pushToMQ(Transformers.toVertxJsonObject(new EnhancedSuccessResponse()
                        .setHeader(request.getHeader())
                        .setCodes(CodeResponse.SuccessCode.PRINT_PDF_REGISTER_SUCCESS.getCode())
                        .setData(gson.toJsonTree(new PdfReportResponse().setPdfLink(config.getReportOutputLink() + reportNameInFolder + ".pdf")))).encode(), QueueKeys.OtherQueue.ADMIN_GENERATE_USER_INFORMATION_PDF.getValue());

            } catch (MalformedURLException e) {
                LOGGER.error("Failed to get Font Config URL. {}", e.toString());
            } catch (BirtException e1) {
                LOGGER.error("Failed to start config. {}", e1.toString());
    //            e1.printStackTrace();
            } catch (
                    Exception e) {
                LOGGER.error("Failed to get design template. {}", e.toString());
                System.err
                        .println("An error occured while running the report!");
                LOGGER.error("An error occured while running the report! {}", e.toString());
    //            e.printStackTrace();
            }
        }


Previous Topic:Get file last modification date
Next Topic:NullPointerException Platform.createFactoryObject
Goto Forum:
  


Current Time: Tue Dec 10 22:41:46 GMT 2019

Powered by FUDForum. Page generated in 0.02021 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top