Excel Emitter error in UNIX box

Megha Nidhi Dahal
edited February 11, 2022 in Analytics #1
Hello Community,<br />
<br />
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.<br />
I tried this in a Windows box and it was working all well.<br />
<br />
But, the same code when ported to a UNIX box, it fails because of some permission issue. The stack trace is as follows:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
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)
</pre>
<br />
By pondering on the exception I have figured out the possible reason to be the lacking permission in '/' directory.<br />
<br />
Now a few things that I don't have any idea are:<br />
1) Why is the '/' considered as temp, it could have been '/tmp'<br />
2) Is there any way that I can override this feature and assign a different temp directory<br />
3) The code snippet to start the engine follows, is there anything else that can be done here<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
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();
</pre>
<br />
Need help ASAP!!!<br />
<br />
regards<br />
Arpan

Comments

  • mwilliams
    edited December 31, 1969 #2
    Hi Arpan,

    A colleague of mine said to try:

    config.setTempDir(tmpDir)

    Hope this helps.
    Warning No formatter is installed for the format ipb
  • Naveen V M
    edited December 31, 1969 #3
    Hi ,

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

    Thanks,
    naveen.
  • Megha Nidhi Dahal
    edited December 31, 1969 #4
    <blockquote class='ipsBlockquote' data-author="'Naveen V M'" data-cid="116026" data-time="1366115893" data-date="16 April 2013 - 05:38 AM"><p>
    Hi ,<br />
    <br />
    I am facing with the same issue, could some one please explain me how can i resolve this issue?<br />
    <br />
    Thanks,<br />
    naveen.<br /></p></blockquote>
    Hi Naveen,<br />
    <br />
    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.<br />
    <br />
    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.<br />
    <br />
    All the best!<br />
    <br />
    Regards,<br />
    Megha Nidhi Dahal