Factory is null after compile

AbeTakaya
edited February 11, 2022 in Analytics #1

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

I'm using BIRT without problem on Esclipse but my new company using IntelliJ IDEA.

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_**** = 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_****", p_****);
                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();
            }
        }

Comments

  • Hi AbeTakaya,

    Could you provide the stack trace with the Null exception?

    The command looks fine, but I have not worked with IntelliJ IDEA before. I'm guessing there is a configuration item here that IntelliJ IDEA isn't picking up/setting. For example, if IntelliJ IDEA isn't showing the OS version (the stack trace would help with this) for the factory then you might need to add an item like System.getProperty(OSname).

    Warning No formatter is installed for the format ipb
  • @jneneman said:
    Hi AbeTakaya,

    Could you provide the stack trace with the Null exception?

    The command looks fine, but I have not worked with IntelliJ IDEA before. I'm guessing there is a configuration item here that IntelliJ IDEA isn't picking up/setting. For example, if IntelliJ IDEA isn't showing the OS version (the stack trace would help with this) for the factory then you might need to add an item like System.getProperty(OSname).

    Hey, i'm really sorry for my late response.

    my stack trace only get me

    2018-10-17 10:23:33.724 [ERROR] [pool-2-thread-4] RegisterService$$EnhancerByGuice$$69986db2 -generateUserInformationPdf vn.intelin.banking.other.services.customerService.RegisterService$$EnhancerByGuice$$69986db2 [795] - Failed to get design template. java.lang.NullPointerException
    An error occured while running the report!
    2018-10-17 10:23:33.726 [ERROR] [pool-2-thread-4] RegisterService$$EnhancerByGuice$$69986db2 -generateUserInformationPdf vn.intelin.banking.other.services.customerService.RegisterService$$EnhancerByGuice$$69986db2 [798] - An error occured while running the report! java.lang.NullPointerException
    java.lang.NullPointerException
        at vn.intelin.banking.other.services.customerService.RegisterService.generateUserInformationPdf(RegisterService.java:721)
        at vn.intelin.banking.other.consumer.ConsumerInternalImpl.blockingStart(ConsumerInternalImpl.java:170)
        at vn.intelin.banking.other.consumer.ConsumerImpl$2.handleDelivery(ConsumerImpl.java:288)
        at com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:144)
        at com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:99)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    

    line 721 is