Excel Emitter error in UNIX box

Megha Nidhi DahalMegha Nidhi Dahal Junior Member
edited February 28, 2011 in Designing Analytics Reports
Hello Community,



Since integration of BIRT 2.6, it has been fairly easy to generate large excel reports. By mentioning large I mean to say such reports which has more than 64k rows.

I tried this in a Windows box and it was working all well.



But, the same code when ported to a UNIX box, it fails because of some permission issue. The stack trace is as follows:


Dec 29, 2010 9:25:16 AM org.eclipse.birt.report.engine.emitter.excel.ExcelEmitter outputSheet

SEVERE: /tmp_BIRTEMITTER_EXCEL_TEMP_FILE27 (Permission denied)

java.io.FileNotFoundException: /tmp_BIRTEMITTER_EXCEL_TEMP_FILE27 (Permission denied)

at java.io.FileOutputStream.open(Native Method)

at java.io.FileOutputStream.<init>(FileOutputStream.java:179)

at java.io.FileOutputStream.<init>(FileOutputStream.java:70)

at org.eclipse.birt.report.engine.emitter.excel.ExcelWriter.initializeWriterAsTempWriter(ExcelWriter.java:166)

at org.eclipse.birt.report.engine.emitter.excel.ExcelWriter.startSheet(ExcelWriter.java:151)

at org.eclipse.birt.report.engine.emitter.excel.ExcelEmitter.outputCacheData(ExcelEmitter.java:543)

at org.eclipse.birt.report.engine.emitter.excel.ExcelEmitter.outputSheet(ExcelEmitter.java:502)

at org.eclipse.birt.report.engine.emitter.excel.layout.ExcelLayoutEngine.outputDataIfBufferIsFull(ExcelLayoutEngine.java:1050)

at org.eclipse.birt.report.engine.emitter.excel.layout.ExcelLayoutEngine.addData(ExcelLayoutEngine.java:933)

at org.eclipse.birt.report.engine.emitter.excel.layout.ExcelLayoutEngine.addData(ExcelLayoutEngine.java:665)

at org.eclipse.birt.report.engine.emitter.excel.ExcelEmitter.addDataContent(ExcelEmitter.java:433)

at org.eclipse.birt.report.engine.emitter.excel.ExcelEmitter.startData(ExcelEmitter.java:390)

at org.eclipse.birt.report.engine.emitter.CompositeContentEmitter.startData(CompositeContentEmitter.java:258)

at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:71)

at org.eclipse.birt.report.engine.layout.html.HTMLTableLayoutEmitter.startContent(HTMLTableLayoutEmitter.java:146)

at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.startText(ContentEmitterAdapter.java:147)

at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.startData(ContentEmitterAdapter.java:163)

at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:71)

at org.eclipse.birt.report.engine.layout.html.buffer.DummyPageBuffer.startContent(DummyPageBuffer.java:125)

at org.eclipse.birt.report.engine.layout.html.HTMLLeafItemLM.start(HTMLLeafItemLM.java:67)

at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:139)

at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)

at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)

at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)

at org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.resumeLayout(HTMLInlineStackingLM.java:111)

at org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.layoutNodes(HTMLInlineStackingLM.java:160)

at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)

at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)

at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)

at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)

at org.eclipse.birt.report.engine.layout.html.HTMLTableBandLM.layoutChildren(HTMLTableBandLM.java:67)

at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)

at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)

at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChildren(HTMLStackingLM.java:26)

at org.eclipse.birt.report.engine.layout.html.HTMLTableLM.layoutChildren(HTMLTableLM.java:132)

at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTMLAbstractLM.java:140)

at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:70)

at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:90)

at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:99)

at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.doRun(RunAndRenderTask.java:172)

at org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.run(RunAndRenderTask.java:75)



By pondering on the exception I have figured out the possible reason to be the lacking permission in '/' directory.



Now a few things that I don't have any idea are:

1) Why is the '/' considered as temp, it could have been '/tmp'

2) Is there any way that I can override this feature and assign a different temp directory

3) The code snippet to start the engine follows, is there anything else that can be done here


URL url = RunBillTask.class.getResource( taskParameters.getDesignFileName() );
if ( url == null )
throw new RunBillTaskException( "Cannot find file " + taskParameters.getDesignFileName() );

// Get the complete file name
String strRptDesign = url.getFile();

IReportEngine engine = null;
String strOutputFileName = "";
try
{
EngineConfig config = new EngineConfig();

String birtHome;

birtHome = System.getenv( "BIRT_HOME" );

if ( birtHome == null )
throw new BillException( "BIRT_HOME not set in system properties" );

config.setEngineHome( birtHome );
config.setLogConfig( FileHelper.sparkTempPath, Level.FINE );

Platform.startup( config );
IReportEngineFactory factory = (IReportEngineFactory)Platform.createFactoryObject( IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY );
engine = factory.createReportEngine( config );
engine.changeLogLevel( Level.SEVERE );

// Open a report design
IReportRunnable design;

design = engine.openReportDesign( strRptDesign );

// Create task to run the report - use the task to execute the
// report and save to disk.
IRunAndRenderTask task = engine.createRunAndRenderTask( design );

RenderOption options = null;
if(taskParameters.getExtension().equals(PDF_EXTENSION))
{
options = new PDFRenderOption();
}
else if(taskParameters.getExtension().equals(EXCEL_EXTENSION))
{
options = new EXCELRenderOption();
((EXCELRenderOption)options).setWrappingText(true);
}

strOutputFileName = FileHelper.sparkTempPathFile + "/" + taskParameters.getOutputFileName() + "." + taskParameters.getExtension();

options.setOutputFileName( strOutputFileName );
options.setOutputFormat( taskParameters.getExtension() );
task.setRenderOption( options );

// Supply the input parameters
for ( ParameterMap< Integer > parameter : taskParameters.getIntParameterList() )
{
task.setParameterValue( parameter.key, parameter.value );
}

for ( ParameterMap< String > parameter : taskParameters.getStrParameterList() )
{
task.setParameterValue( parameter.key, parameter.value );
}

for ( ParameterMap< Boolean > parameter : taskParameters.getBoolParameterList() )
{
task.setParameterValue( parameter.key, parameter.value );
}

for ( ParameterMap< Double > parameter : taskParameters.getDecimalParameterList() )
{
task.setParameterValue( parameter.key, parameter.value );
}

for ( ParameterMap< Float > parameter : taskParameters.getFloatParameterList() )
{
task.setParameterValue( parameter.key, parameter.value );
}

// run the report and destroy the engine
task.run();

task.close();



Need help ASAP!!!



regards

Arpan

Comments

  • mwilliamsmwilliams BIRT Guru
    edited December 31, 1969
    Hi Arpan,

    A colleague of mine said to try:

    config.setTempDir(tmpDir)

    Hope this helps.

    Regards,

    Michael Williams

    eSignLive Evangelism & Community Manager | eSignLive by VASCO
     
    Find me on:
    Twitter
    Facebook
    Blog

    LinkedIn

    eSignLive Developer Community
     
    Email me:
    Google: [email protected]

  • edited December 31, 1969
    Hi ,

    I am facing with the same issue, could some one please explain me how can i resolve this issue?

    Thanks,
    naveen.
  • Megha Nidhi DahalMegha Nidhi Dahal Junior Member
    edited December 31, 1969


    Hi ,



    I am facing with the same issue, could some one please explain me how can i resolve this issue?



    Thanks,

    naveen.


    Hi Naveen,



    The very first thing you should try is to run your code with super user privileges. This will prove if the problem is of permission or not.



    Next you can try out the option that Michael has suggested. It has been a long time since I encountered this issue, but I think setting the temp directory explicitly will also do the job.



    All the best!



    Regards,

    Megha Nidhi Dahal
Sign In or Register to comment.