RE: BIRT Integration with Liferay DXP 7.4 u77

Olaf Kock, modified 1 Year ago. New Member Post: 1 Join Date: 11/1/23 Recent Posts

Hello everyone i am using Liferay 7.4 u77  version and I'm using birt 4.4.2 version i want to generate the birt report using Liferay mvc portlet  i added all the dependencies related to birt but I'm unable to get the     IReportEngineFactory factory = (IReportEngineFactory) Platform
                    .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
I'm unable to get the factory object  i m sharing my complete code for birt report generation 

    private IReportEngine getReportEngine() {
        IReportEngine engine = null;
        EngineConfig config =  null;
        try {
            config = new EngineConfig();
               Platform.startup(config);
            IReportEngineFactory factory = (IReportEngineFactory) Platform
                    .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
            engine = factory.createReportEngine(config);
               engine.changeLogLevel( Level.WARNING );
        } catch (BirtException ex) {
            LOGGER.error(ex);
        }
        return engine;
    }

@Override
    public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
            throws IOException, PortletException {
        
          IRunAndRenderTask runAndRenderTask = null;
          try { 
              
              IReportEngine reportEngine = getReportEngine();
          IReportRunnable report = reportEngine.openReportDesign("C:\\work\\test\\new_report.rptdesign");
          runAndRenderTask = reportEngine.createRunAndRenderTask(report);
          renderResponse.setContentType(reportEngine.getMIMEType("pdf"));
          IRenderOption options = new RenderOption();
          PDFRenderOption pdfRenderOption = new
          PDFRenderOption(options);
          pdfRenderOption.setOutputFormat("pdf");
          runAndRenderTask.setRenderOption(pdfRenderOption);
          runAndRenderTask.getAppContext().put(EngineConstants.
          APPCONTEXT_PDF_RENDER_CONTEXT, renderResponse);          
          HttpServletResponse response =
          PortalUtil.getHttpServletResponse(renderResponse);
          response.addHeader("Content-disposition", "attachment; filename=ria-report.pdf");
                pdfRenderOption.setOutputStream(response.getOutputStream());
                runAndRenderTask.run();
            } catch (Exception e) {
                LOGGER.error(e);
            }
            
          super.doView(renderRequest, renderResponse);
    }
Thanks

thumbnail
Olaf Kock, modified 1 Year ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

As discussed on Slack, this is rather a question for the BIRT community.

Leading up to this point, you were adding transitive dependencies, until you didn't get any more problems with static binding. My assumption is that it's still possible that the BIRT framework can't find more (optional) transitive dependencies that are technically optional (thus: statically it works), but practically​​​​​​​ required for the configuration that you attempt to use (thus: The framework doesn't provide you with a factory).

Fine if someone can help here, but I guess the BIRT community might have it easier to identify missing libraries. When you ask there, please provide them with the list of transitive dependencies that you already have added to your system, and ask which additional ones you might be missing.

thumbnail
Olaf Kock, modified 1 Year ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

Also: I find a number of hits when searching for "BIRT createFactoryObject null" - you might want to dig among those.