Community
Participate
Working Groups
Build Identifier: public void main() throws BirtException, FileNotFoundException { generateReport(); // ok generateReport(); // exception see below } public void generateReport() throws BirtException, FileNotFoundException { String birtHomeDirectory = "..."; String fileNameReport = "..."; String fileNameDataset = "..."; EngineConfig config = new EngineConfig(); config.setEngineHome(birtHomeDirectory); Platform.startup(config); IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY ); IReportEngine engine = factory.createReportEngine( config ); IReportRunnable design = engine.openReportDesign(new FileInputStream(fileNameReport)); ReportDesignHandle reportDesignHandle = (ReportDesignHandle) design.getDesignHandle(); OdaDataSourceHandle dsHandle = (OdaDataSourceHandle) reportDesignHandle.getDataSources().get(0); dsHandle.setProperty("FILELIST", fileNameDataset); dsHandle.setProperty( "ENCODINGLIST", "UTF-8" ); IRunAndRenderTask task = engine.createRunAndRenderTask(design); HashMap contextMap = new HashMap(); task.setAppContext(contextMap); PDFRenderOption options = new PDFRenderOption(); options.setOutputStream(new ByteArrayOutputStream()); options.setOutputFormat("pdf"); task.setRenderOption(options); task.run(); task.close(); engine.destroy(); Platform.shutdown(); } --- Exception thrown second time: 26.05.2010 00:24:28 org.eclipse.birt.report.data.adapter.impl.ModelAdapter adaptDataSet WARNUNG: handle type: org.eclipse.birt.report.model.api.OdaDataSetHandle Exception in thread "main" org.eclipse.birt.report.model.api.command.PropertyNameException: The property "FILELIST" is invalid for element "Data Source". at org.eclipse.birt.report.model.command.PropertyCommand.setProperty(PropertyCommand.java:129) at org.eclipse.birt.report.model.api.DesignElementHandle.setProperty(DesignElementHandle.java:520) at com.ds.common.reportserver.server.BirtEngineTest.generateReport(BirtEngineTest.java:59) at com.ds.common.reportserver.server.BirtEngineTest.main(BirtEngineTest.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:110) Reproducible: Always
OdaDataSourceHandle dsHandle = (OdaDataSourceHandle) reportDesignHandle.getDataSources().get(0); dsHandle.setProperty("FILELIST", fileNameDataset); dsHandle.setProperty( "ENCODINGLIST", "UTF-8" ); The data set has no such property. What's the purpose?
i need to set the dataset while executing the report to a dynamically generated xml-file. there is no such property? but the first run works!? i found this solution in this faq: ftp://ftp-developpez.com/business-intelligence/faq/birt/faqbirt.pdf
sorry: i need to set the data source dynamically
(In reply to comment #2) > i need to set the dataset while executing the report to a dynamically generated > xml-file. > > there is no such property? but the first run works!? > > i found this solution in this faq: > ftp://ftp-developpez.com/business-intelligence/faq/birt/faqbirt.pdf Do you use ODA data source? Only for ODA data source, it can define its own properties. Can you please attach the report design. BTW, I cannot access the pdf you mentioned.
Created attachment 169946 [details] report for testcase
yes - i used an oda data source. i there another way? BTW: pdf on ftp works for me ;)
Created attachment 169947 [details] xml datasource for testcase
As a workaround, you can start and shutdown the platform only once. For example: public void main() throws BirtException, FileNotFoundException { startEngine(); generateReport(); // ok generateReport(); // exception see below shutdownEngine(); } IReportEngine engine; public void startEngine() { String birtHomeDirectory = "..."; EngineConfig config = new EngineConfig(); config.setEngineHome(birtHomeDirectory); Platform.startup(config); IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY ); engine = factory.createReportEngine( config ); } public shutdownEngine() { engine.destroy(); Platform.shutdown(); engine = null; } public void generateReport() throws BirtException, FileNotFoundException { String fileNameReport = "..."; String fileNameDataset = "..."; IReportRunnable design = engine.openReportDesign(new FileInputStream(fileNameReport)); ReportDesignHandle reportDesignHandle = (ReportDesignHandle) design.getDesignHandle(); OdaDataSourceHandle dsHandle = (OdaDataSourceHandle) reportDesignHandle.getDataSources().get(0); dsHandle.setProperty("FILELIST", fileNameDataset); dsHandle.setProperty( "ENCODINGLIST", "UTF-8" ); IRunAndRenderTask task = engine.createRunAndRenderTask(design); HashMap contextMap = new HashMap(); task.setAppContext(contextMap); PDFRenderOption options = new PDFRenderOption(); options.setOutputStream(new ByteArrayOutputStream()); options.setOutputFormat("pdf"); task.setRenderOption(options); task.run(); task.close(); }
I've simplified the usecase for reproduction. My original program only restarts the engine, if the first generating step fails. If i do not restart the engine after an exception, it will sometimes hang up during the second step.
Looks like there is some issue for class loading for the 2nd time to run report. Will get back to you later.
fixed.
Verified in build (2.6.1.v20100623-0603).