[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[birt-report-engine-dev] engine.openReportDocument methos is throwing exception

Hi,

I have a requirement where I want to run task one time and generate a IReportDocument, So that report I can use at different place to render (e.g. export etc) . For this purpose I have serialized all my model classes.

But I am finiding exception when I am trying to use engine.openReportDocument  , any help will be highly appreciated. java, script and Exception is below :
 
//////////////////////////////Exception/////

Dec 8, 2009 7:09:45 PM

INFO: Parser is initialized

Dec 8, 2009 7:09:56 PM org.eclipse.birt.report.engine.api.impl.ReportDocumentReader loadCoreStreamLazily

SEVERE: Failed to load core stream

java.io.IOException

: com.rsa.esi.reports.model.VariableElement

at org.eclipse.birt.core.util.IOUtil.readObject(

IOUtil.java:525)

at org.eclipse.birt.core.util.IOUtil.readList(

IOUtil.java:813)

at org.eclipse.birt.core.util.IOUtil.readObject(

IOUtil.java:497)

at org.eclipse.birt.core.util.IOUtil.readMap(

IOUtil.java:888)

at org.eclipse.birt.core.util.IOUtil.readObject(

IOUtil.java:500)

at org.eclipse.birt.core.util.IOUtil.readMap(

IOUtil.java:888)

at org.eclipse.birt.report.engine.api.impl.ReportDocumentReader.loadCoreStreamBodyV2(

ReportDocumentReader.java:512)

at org.eclipse.birt.report.engine.api.impl.ReportDocumentReader.loadCoreStreamBody(

ReportDocumentReader.java:456)

at org.eclipse.birt.report.engine.api.impl.ReportDocumentReader.loadCoreStream(

ReportDocumentReader.java:408)

at org.eclipse.birt.report.engine.api.impl.ReportDocumentReader.loadCoreStream(

ReportDocumentReader.java:386)

at org.eclipse.birt.report.engine.api.impl.ReportDocumentReader.loadCoreStreamLazily(

ReportDocumentReader.java:347)

at org.eclipse.birt.report.engine.api.impl.ReportDocumentReader.getParameterValues(

ReportDocumentReader.java:888)

at org.eclipse.birt.report.engine.api.impl.RenderTask.<init>(

RenderTask.java:127)

at org.eclipse.birt.report.engine.api.impl.RenderTask.<init>(

RenderTask.java:78)

at org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.createRenderTask(

ReportEngineHelper.java:458)

at org.eclipse.birt.report.engine.api.impl.ReportEngine.createRenderTask(

ReportEngine.java:520)

at com.aaa.bbb.reports.actions.ESIReportAction.createReport(

ESIReportAction.java:69)

at com.aaa.bbb.rcp.ApplicationActionBarAdvisor$1.run(

ApplicationActionBarAdvisor.java:228)

at org.eclipse.jface.action.Action.runWithEvent(

Action.java:498)

at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(

ActionContributionItem.java:583)

at org.eclipse.jface.action.ActionContributionItem.access$2(

ActionContributionItem.java:500)

at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(

ActionContributionItem.java:411)

at org.eclipse.swt.widgets.EventTable.sendEvent(

EventTable.java:84)

at org.eclipse.swt.widgets.Widget.sendEvent(

Widget.java:1003)

at org.eclipse.swt.widgets.Display.runDeferredEvents(

Display.java:3823)

at org.eclipse.swt.widgets.Display.readAndDispatch(

Display.java:3422)

at org.eclipse.ui.internal.Workbench.runEventLoop(

Workbench.java:2384)

at org.eclipse.ui.internal.Workbench.runUI(

Workbench.java:2348)

at org.eclipse.ui.internal.Workbench.access$4(

Workbench.java:2200)

at org.eclipse.ui.internal.Workbench$5.run(

Workbench.java:495)

at org.eclipse.core.databinding.observable.Realm.runWithDefault(

Realm.java:288)

at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(

Workbench.java:490)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(

PlatformUI.java:149)

at com.aaa.bbb.rcp.Application.start(

Application.java:59)

at org.eclipse.equinox.internal.app.EclipseAppHandle.run(

EclipseAppHandle.java:193)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(

EclipseAppLauncher.java:110)

at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(

EclipseAppLauncher.java:79)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(

EclipseStarter.java:386)

at org.eclipse.core.runtime.adaptor.EclipseStarter.run(

EclipseStarter.java:179)

at sun.reflect.NativeMethodAccessorImpl.invoke0(

Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.eclipse.equinox.launcher.Main.invokeFramework(

Main.java:549)

at org.eclipse.equinox.launcher.Main.basicRun(

Main.java:504)

at org.eclipse.equinox.launcher.Main.run(

Main.java:1236)

at org.eclipse.equinox.launcher.Main.main(

Main.java:1212)

Dec 8, 2009 7:09:56 PM org.eclipse.birt.report.engine.api.impl.ReportDocumentReader loadCoreStreamLazily

SEVERE: Failed to load core stream

//////////////////////////////////////Exception END/////////////////
 
 






Below is java and script code I am using. problematic code is in bold.
/////////////////////////////////////JAVA CODE ///////////////////////////////////////////


package com.aaa.bbb.report.view;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.HashMap;

import org.eclipse.birt.core.framework.Platform;
import org.eclipse.birt.report.engine.api.EXCELRenderOption;
import org.eclipse.birt.report.engine.api.EngineConfig;
import org.eclipse.birt.report.engine.api.EngineConstants;
import org.eclipse.birt.report.engine.api.EngineException;
import org.eclipse.birt.report.engine.api.HTMLRenderContext;
import org.eclipse.birt.report.engine.api.HTMLRenderOption;
import org.eclipse.birt.report.engine.api.IRenderOption;
import org.eclipse.birt.report.engine.api.IRenderTask;
import org.eclipse.birt.report.engine.api.IReportDocument;
import org.eclipse.birt.report.engine.api.IReportEngine;
import org.eclipse.birt.report.engine.api.IReportEngineFactory;
import org.eclipse.birt.report.engine.api.IReportRunnable;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;
import org.eclipse.birt.report.engine.api.IRunTask;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;

public class SampleView extends ViewPart
{
    public static final String ID = "org.eclipse.birt.examples.rcpengine.view";

    private Browser browser;

    /**
     * This is a callback that will allow us to create the viewer and initialize
     * it.
     */
    public void createPartControl(Composite parent) {
        parent.setLayout(new GridLayout());
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        Group reportGroup = new Group(parent, SWT.SHADOW_IN);
        reportGroup.setText("Select report:");
        GridLayout layout = new GridLayout(2, false);
        reportGroup.setLayout(layout);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        reportGroup.setLayoutData(gd);

        gd = new GridData();
        gd.horizontalSpan = 2;

        Label label = new Label(reportGroup, SWT.NONE);
        label.setText("Full Path:");

        label.setLayoutData(gd);


        Button showReport = new Button(reportGroup, SWT.PUSH);
        showReport.setText("Run Report");

        showReport.addSelectionListener(new SelectionListener() {

            public void widgetSelected(SelectionEvent e) {
                try {
                    createReport();
                } catch (Exception exp) {
                    exp.printStackTrace();
                }
                // addReportParameters(lParent, gridData);
                // openReportRunner();
            }

            public void widgetDefaultSelected(SelectionEvent e) {
                // TODO Auto-generated method stub

            }
        });

        browser = new Browser(parent, SWT.NONE);
        gd = new GridData(GridData.FILL_BOTH);
        gd.horizontalSpan = 2;
        browser.setLayoutData(gd);

    }

    private void createReport() throws EngineException {

        EngineConfig config = new EngineConfig();

        // Create the report engine
        IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
        IReportEngine engine = factory.createReportEngine( config );

        IReportRunnable design = null;
        try {
            // Open a report design
            FileInputStream fs = new FileInputStream("C:\\MySpace\\EclipseWorkspace\\Report\\test2\\envision\\esi\\com.rsa.esi.report\\src\\esireport_final.rptdesign");
            design = engine.openReportDesign(fs);
            IRunTask task = engine.createRunTask(design);
           
            task.run("C:/tempmock.rptdocument");
            IReportDocument ird = engine.openReportDocument("C:/tempmock.rptdocument");

            IRenderTask renderTask = engine.createRenderTask(ird);

            // Set rendering options   
            //EXCELRenderOption xlsRenderoptions = new EXCELRenderOption();
            HTMLRenderOption htmlRenderOptions = new HTMLRenderOption();
           
            //ByteArrayOutputStream bos = new ByteArrayOutputStream();
            //FileOutputStream xlsStrem = new FileOutputStream("C:/temp.xls");
            FileOutputStream htmlStrem = new FileOutputStream("C:/temp.html");
           
            //xlsRenderoptions.setOutputStream(xlsStrem);
            //options.setOutputFormat(IRenderOption.OUTPUT_FORMAT_HTML);

            htmlRenderOptions.setOutputStream(htmlStrem);
            renderTask.setRenderOption(htmlRenderOptions);
            htmlRenderOptions.setOutputFormat(IRenderOption.OUTPUT_FORMAT_HTML);
           
           
            // run the report and destroy the engine
            renderTask.render();
           
            htmlStrem.close();
            //xlsStrem.close();
            //set Browser text accordingly
            //browser.setText(bos.toString());
            browser.setUrl("C:/temp.html");
           
            engine.destroy();

        }
        catch (Exception e) {
            e.printStackTrace();

        }

    }

    /**
     * Passing the focus request to the viewer's control.
     */
    public void setFocus() {

    }
}


//////////////////////////////////////////////////////////////////////////////////////////////////  END OF JAVA CODE////////////////////////////////////////////////////

/////////////////////////////////////  Script CODE

importPackage( Packages.java.util );
importPackage( Packages.java.lang );
importPackage(Packages.org.eclipse.core.runtime);

var eventList = new ArrayList();
var headerMap = new Hashtable();
var messageMap = new Hashtable();
var headerVarMap = new Hashtable();
var messageVarMap = new Hashtable();

/*
 * load and init data reader
 * import Platform from org.eclipse.core.runtime
 */

/* load bundle with POJOs and data loading class */
myBundle = Platform.getBundle("com.aaa.bbb.report");

/* load data reader class */
readerClass = myBundle.loadClass("com.aaa.bbb.report.data.TestReportData");

/* create new instance of DataReader */
readerInstance = readerClass.newInstance();

//Load the List
var gtestDataList = readerInstance.createReportData();

for ( i=0; i < gtestDataList.size(); i++ )
{
    var event = gtestDataList.get(i).getEvent();
    var hdrDataList = gtestDataList.get(i).getHdrDataList();
    var msgDataList = gtestDataList.get(i).getMsgDataList();
   
       eventList.add(event);
   
    messageMap.put( event, msgDataList);
    headerMap.put( event, hdrDataList);
   
   
   
    for(j=0; j < msgDataList.size(); j++)
    {
        var msgData = msgDataList.get(j);
        messageVarMap.put(event+msgData.getMessageID(),msgData.getMsgVars());
    }
    for(j=0; j < hdrDataList.size(); j++)
    {
        var hdrData = hdrDataList.get(j);
        headerVarMap.put(event+hdrData.getHeaderID(),hdrData.getHdrVars());
    }
}

reportContext.setPersistentGlobalVariable("eventList", eventList);
reportContext.setPersistentGlobalVariable("headerMap", headerMap);
reportContext.setPersistentGlobalVariable("messageMap", messageMap);
reportContext.setPersistentGlobalVariable("headerVarMap", headerVarMap);
reportContext.setPersistentGlobalVariable("messageVarMap", messageVarMap);