Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316239 - Require for patch: NPE when generate MS word using BIRT
Summary: Require for patch: NPE when generate MS word using BIRT
Status: VERIFIED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 2.6.1   Edit
Assignee: Gang Liu CLA
QA Contact: Xiaodan Wang CLA
URL:
Whiteboard: Obsolete
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-09 01:11 EDT by Alex Chen CLA
Modified: 2010-09-19 23:36 EDT (History)
2 users (show)

See Also:


Attachments
provide the patch for this bug (974 bytes, application/octet-stream)
2010-08-02 02:18 EDT, Alex Chen CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Chen CLA 2010-06-09 01:11:12 EDT
Build Identifier: 2.5.2

We use BIRT engine API to generate MS word document in our code, but we get NPE when we upgrade to Eclipse 3.5.2:

=========================================
Jun 3, 2010 4:09:02 PM org.eclipse.birt.report.engine.api.impl.RunTask doRun
SEVERE: An error happened while running the report. Cause:
Throwable occurred: java.lang.NullPointerException
at org.eclipse.birt.report.engine.nLayout.area.impl.TableArea.s plit(TableArea.java:296)
at org.eclipse.birt.report.engine.nLayout.area.impl.BlockContai nerArea._split(BlockContainerArea.java:366)
at org.eclipse.birt.report.engine.nLayout.area.impl.BlockContai nerArea.split(BlockContainerArea.java:308)
at org.eclipse.birt.report.engine.nLayout.area.impl.BlockContai nerArea._split(BlockContainerArea.java:366)
at org.eclipse.birt.report.engine.nLayout.area.impl.BlockContai nerArea.split(BlockContainerArea.java:308)
at org.eclipse.birt.report.engine.nLayout.area.impl.BlockContai nerArea._split(BlockContainerArea.java:366)
at org.eclipse.birt.report.engine.nLayout.area.impl.BlockContai nerArea.split(BlockContainerArea.java:308)
at org.eclipse.birt.report.engine.nLayout.area.impl.RowArea._sp lit(RowArea.java:318)
===========================================

In Eclipse 3.5.2, the engine is org.eclipse.birt.report.engine_2.5.2.v20100210.jar, after checking CVS of BIRT, we find it has been fixed start from version 1.21.2.1 and 1.22 around 2010-05-10,  http://dev.eclipse.org/viewcvs/index.cgi/source/org.eclipse. birt.report.engine/src/org/eclipse/birt/report/engine/nLayou t/area/impl/TableArea.java?root=BIRT_Project&view=log

So could BIRT guys create a feature patch(need since Eclipse 3.4.x, http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.pde.doc.user/guide/tools/project_wizards/new_feature_patch.htm) based on Eclipse 3.5.2 for this fix? we need it in our product.

Thanks much!
--Alex

Reproducible: Always
Comment 1 Jun Ouyang CLA 2010-06-09 01:16:11 EDT
Can you attach your code? Can you double check if you did set "doc" as output format?
Generating word document doesn't use any code in package org.eclipse.birt.report.engine.nLayout.area.*
Comment 2 Alex Chen CLA 2010-06-09 01:32:38 EDT
(In reply to comment #1)
> Can you attach your code? Can you double check if you did set "doc" as output
> format?
> Generating word document doesn't use any code in package
> org.eclipse.birt.report.engine.nLayout.area.*

The exception happened on generating step but rendering step, we do set "doc" in the option in the rendering step.

=================
	public void doGeneration(IProgressMonitor monitor){
		MethodConfiguration config = options.getConfig();
		String designName = outputPath + File.separator + config.getName() + ".rptdesign"; //$NON-NLS-1$
		IReportRunnable design = null;
		try {
			design = engine.openReportDesign(designName);
		} catch (EngineException e1) {
			logger.log(Level.SEVERE, PublishingDocResource.openReportDesignFail, e1);
			return;
		}
		runTask = engine.createRunTask(design);
		ReportDesignHandle designHandle = (ReportDesignHandle)design.getDesignHandle();
		if(designHandle.findParameter(TemplateManager.PARAM_SHOWDESCRIPTORS)!=null)
			runTask.setParameterValue(TemplateManager.PARAM_SHOWDESCRIPTORS, 
					options.isShowDescriptorsInNavigationTree());
		if(designHandle.findParameter(TemplateManager.PARAM_PUBLISHDESCRIPTORS)!=null)
			runTask.setParameterValue(TemplateManager.PARAM_PUBLISHDESCRIPTORS, 
					options.isShowRelatedDescriptors());
		designHandle.close();
		docFile = outputPath+File.separator+config.getName()+".rptdocument"; //$NON-NLS-1$
		monitor.subTask(PublishingDocResource.generatingReportDocument);			
		runTask.setAppContext(new HashMap());
		Runnable runnable = new Runnable(){				
			public void run() {					
				try {
//					Context.enter();
					runTask.run(docFile);
//					Context.exit();
				} catch (EngineException e) {						
					logger.log(Level.SEVERE, "", e); //$NON-NLS-1$				
				}				
			}							
		};						
		Thread th = new Thread(runnable);			
		th.start();						
		while(runTask.getStatus()==IEngineTask.STATUS_NOT_STARTED || 					
				runTask.getStatus()==IEngineTask.STATUS_RUNNING){				
			if(monitor.isCanceled()){					
				runTask.cancel();				
			}				
			try {					
				Thread.sleep(100);				
			} catch (InterruptedException e) {					
				logger.log(Level.WARNING, "", e); //$NON-NLS-1$			
			}			
		}			
//		runTask.close();	
		if(runTask.getStatus()!=IEngineTask.STATUS_SUCCEEDED)
			status = IStatus.ERROR;
		runTask = null;
		config = null;
		Runtime.getRuntime().gc();
	}
	
	public void doPresentation(IProgressMonitor monitor){
		if(status == IStatus.ERROR) return;
		IReportDocument doc = null;
		try {
//			doc = engine.openReportDocument(docFile);
			doc = ReportDocument.getInstance(engine, docFile, toc);
		} catch (EngineException e1) {
			PublishDocPlugin.getDefault().getLogger().logError(e1);	
		}
		renderTask = engine.createRenderTask(doc);
		RenderOption option = new RenderOption();
		option.setOption(PDFRenderOption.FIT_TO_PAGE, false);
		option.setOption(PDFRenderOption.PAGEBREAK_PAGINATION_ONLY, false);
		option.setOption(PDFRenderOption.HTML_PAGINATION, false);
		output = options.getOutputFilename();
		option.setOutputFileName(output);
		if(options.getOutputFormat()==PublishDocOptions.OUTPUT_FORMAT_PDF)
			option.setOutputFormat(IRenderOption.OUTPUT_FORMAT_PDF);
		else if(options.getOutputFormat()==PublishDocOptions.OUTPUT_FORMAT_MSWORD)
			option.setOutputFormat("doc"); //$NON-NLS-1$
		option.setSupportedImageFormats("JPG;PNG;BMP;SVG"); //$NON-NLS-1$
//		option.setOption("htmlPagination", Boolean.TRUE); //$NON-NLS-1$
		renderTask.setRenderOption(option);
		monitor.subTask(PublishingDocResource.renderingReport);		
		renderTask.setAppContext(new HashMap());
		Runnable runnable = new Runnable(){				
			public void run() {					
				try {
//					Context.enter();
					renderTask.render();
//					Context.exit();
				} catch (EngineException e) {						
					PublishDocPlugin.getDefault().getLogger().logError(e);				
				}				
			}							
		};						
		Thread th = new Thread(runnable);			
		th.start();						
		while(renderTask.getStatus()==IEngineTask.STATUS_NOT_STARTED || 					
				renderTask.getStatus()==IEngineTask.STATUS_RUNNING){				
			if(monitor.isCanceled()){					
				renderTask.cancel();				
			}				
			try {					
				Thread.sleep(100);				
			} catch (InterruptedException e) {					
				PublishDocPlugin.getDefault().getLogger().logError(e);					
			}			
		}
//		renderTask.close();
		doc.close();
		if(renderTask.getStatus()==IEngineTask.STATUS_SUCCEEDED)
			status = IStatus.OK;
		renderTask = null;
	}
=================
Comment 3 Gang Liu CLA 2010-07-12 00:53:24 EDT
 defer to future.
Comment 4 Gang Liu CLA 2010-07-12 00:54:32 EDT
Please ignore the last operation
Comment 5 Xiaoying Gu CLA 2010-07-22 03:53:17 EDT
(In reply to comment #0)
> Build Identifier: 2.5.2
> 
> We use BIRT engine API to generate MS word document in our code, but we get NPE
> when we upgrade to Eclipse 3.5.2:
> 

Can you preview the report as DOC in BIRT designer 2.5.2?
Comment 6 Alex Chen CLA 2010-08-02 02:18:31 EDT
Created attachment 175683 [details]
provide the patch for this bug
Comment 7 Gang Liu CLA 2010-09-15 04:40:49 EDT
This bug exists in 2.6.0M3-2.6.0M7, it had been fixed since 2.6.0RC1
fixed.
Comment 8 Xiaodan Wang CLA 2010-09-19 23:36:14 EDT
Verified in build (2.6.1.v20100915-1750).