Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 314375

Summary: Failed report process after restart standalone BIRT engine
Product: z_Archived Reporter: Christoph Henniger <henniger>
Component: BIRTAssignee: Xuelan Li <xuelan.li>
Status: VERIFIED FIXED QA Contact: Xiaodan Wang <xwang>
Severity: normal    
Priority: P3 CC: bluesoldier, rlu, wyan
Version: 2.5.2   
Target Milestone: 2.6.0 RC4   
Hardware: PC   
OS: Linux   
Whiteboard: Non-Auto
Attachments:
Description Flags
report for testcase
none
xml datasource for testcase none

Description Christoph Henniger CLA 2010-05-25 18:30:56 EDT
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
Comment 1 Rick Lu CLA 2010-05-26 04:01:08 EDT
    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?
Comment 2 Christoph Henniger CLA 2010-05-26 04:08:40 EDT
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
Comment 3 Christoph Henniger CLA 2010-05-26 04:10:13 EDT
sorry: i need to set the data source dynamically
Comment 4 Rick Lu CLA 2010-05-26 04:29:50 EDT
(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.
Comment 5 Christoph Henniger CLA 2010-05-26 04:34:28 EDT
Created attachment 169946 [details]
report for testcase
Comment 6 Christoph Henniger CLA 2010-05-26 04:37:11 EDT
yes - i used an oda data source. i there another way?

BTW: pdf on ftp works for me ;)
Comment 7 Christoph Henniger CLA 2010-05-26 04:40:47 EDT
Created attachment 169947 [details]
xml datasource for testcase
Comment 8 Wei Yan CLA 2010-05-26 04:43:09 EDT
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();
}
Comment 9 Christoph Henniger CLA 2010-05-26 04:50:11 EDT
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.
Comment 10 Rick Lu CLA 2010-05-26 04:51:18 EDT
Looks like there is some issue for class loading for the 2nd time to run report. Will get back to you later.
Comment 11 Xuelan Li CLA 2010-06-02 23:31:11 EDT
fixed.
Comment 12 Xiaodan Wang CLA 2010-06-24 02:08:43 EDT
Verified in build (2.6.1.v20100623-0603).