Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
IReportRunnable is not Succeeded
skumarcse
<p>I am using BIRT runtime 4.4.1 and trying to generate the letters in Java application using Eclipse Luna 64 bit Windows 7. I noticed that while debugging when cross IReportRunnable line, the method abruptly quit and return to Callee method. When tried to Step Into openReportDesign(...), Eclipse shows "source not found" for ReportEngine Class whereas Birt runtime JAR (org.eclipse.birt.runtime_4.4.1.v20140916-1320.jar) file exists on Eclipse Build Path. So, where I am missing to connect the Dots ?</p>
<p> </p>
<div>String reportFilePath="C:\\birt-runtime-4_4_1\\LetterDesigns\\dueDate.rptdesign";</div>
<div>IReportRunnable ireportDocument = engine.openReportDesign(new FileInputStream(new File(reportFilePath)));</div>
<div> </div>
<div>PS : I tried to use IRunTask to create run task in order find internal error. But, Seems like IReportRunnable needs succeeded in order to create IRunTask instance. May be I do not know other options to find internal errors. Could you please help me on this ?</div>
Find more posts tagged with
Comments
mwilliams
<p>Could you post your entire java class so I can set it up as you have it for testing? Thanks.</p>
skumarcse
<p>Here is Class file where exception throws when execute task.run() method (task is instance of IRunAndRenderTask).</p>
<p> </p>
<div>import java.io.File;</div>
<div>import java.io.FileInputStream;</div>
<div>import java.io.FileNotFoundException;</div>
<div>import java.io.InputStream;</div>
<div>import java.io.OutputStream;</div>
<div>import java.util.List;</div>
<div>import java.util.Map;</div>
<div>import java.util.Properties;</div>
<div> </div>
<div>import org.apache.log4j.Logger;</div>
<div>import org.eclipse.birt.core.exception.BirtException;</div>
<div>import org.eclipse.birt.core.framework.Platform;</div>
<div>import org.eclipse.birt.report.engine.api.EngineConfig;</div>
<div>import org.eclipse.birt.report.engine.api.EngineConstants;</div>
<div>import org.eclipse.birt.report.engine.api.EngineException;</div>
<div>import org.eclipse.birt.report.engine.api.HTMLRenderContext;</div>
<div>import org.eclipse.birt.report.engine.api.HTMLRenderOption;</div>
<div>import org.eclipse.birt.report.engine.api.IReportEngine;</div>
<div>import org.eclipse.birt.report.engine.api.IReportEngineFactory;</div>
<div>import org.eclipse.birt.report.engine.api.IReportRunnable;</div>
<div>import org.eclipse.birt.report.engine.api.IRunAndRenderTask;</div>
<div>import org.eclipse.birt.report.engine.api.IRunTask;</div>
<div>import org.eclipse.birt.report.engine.api.PDFRenderOption;</div>
<div>import org.eclipse.birt.report.engine.api.RenderOption;</div>
<div>import org.eclipse.birt.report.engine.api.ReportEngine;</div>
<div>import org.eclipse.birt.report.engine.api.impl.RunTask;</div>
<div>import org.eclipse.core.internal.registry.RegistryProviderFactory;</div>
<div> </div>
<div>import com.birt.letters.LetterGenerator;</div>
<div>import com.birt.letters.LetterGeneratorException;</div>
<div> </div>
<div>import java.util.logging.Level;</div>
<div> </div>
<div>public class LetterGeneratorBIRTImpl implements LetterGenerator {</div>
<div>private static Logger log = Logger.getLogger(LetterGenerator.class);</div>
<div> </div>
<div>// private static Log log = LogFactory</div>
<div>// .getLog(LetterGeneratorBIRTImpl.class);</div>
<div>public static final String PROP_BIRT_HOME = "com.birt.letters.BIRT.Home";</div>
<div>public static final String PROP_BIRT_LOG_HOME = "com.birt.letters.BIRT.LogHome";</div>
<div>public static final String PROP_BIRT_HTML_IMGS = "com.birt.letters.BIRT.html.Images";</div>
<div> </div>
<div>protected IReportEngine engine = null;</div>
<div>protected EngineConfig config = null;</div>
<div>protected String birtHome = null;</div>
<div>protected String birtLogHome = null;</div>
<div>protected String htmlImgHome = null;</div>
<div> </div>
<div>/*</div>
<div>* (non-Javadoc)</div>
<div>* </div>
<div>*
@see
com.birt.letters.LetterGenerator#init(java.util.Properties)</div>
<div>*/</div>
<div>public void init(Properties properties) throws LetterGeneratorException {</div>
<div>this.birtHome = properties.getProperty(PROP_BIRT_HOME, this.birtHome);</div>
<div>this.birtLogHome = properties.getProperty(PROP_BIRT_LOG_HOME,</div>
<div>this.birtLogHome);</div>
<div>this.htmlImgHome = properties.getProperty(PROP_BIRT_HTML_IMGS);</div>
<div>initEngine();</div>
<div>}</div>
<div> </div>
<div>/*</div>
<div>* (non-Javadoc)</div>
<div>* </div>
<div>*
@see
com.birt.letters.LetterGenerator#init(java.util.Map)</div>
<div>*/</div>
<div>public void init(Map<String, String> prop) throws LetterGeneratorException {</div>
<div>if (prop.containsKey(PROP_BIRT_HOME))</div>
<div>this.birtHome = prop.get(PROP_BIRT_HOME);</div>
<div>if (prop.containsKey(PROP_BIRT_LOG_HOME))</div>
<div>this.birtLogHome = prop.get(PROP_BIRT_LOG_HOME);</div>
<div>initEngine();</div>
<div>}</div>
<div> </div>
<div>/*</div>
<div>* (non-Javadoc)</div>
<div>* </div>
<div>*
@see
com.birt.letters.LetterGenerator#done()</div>
<div>*/</div>
<div>public void done() {</div>
<div>Platform.shutdown();</div>
<div>}</div>
<div> </div>
<div>/**</div>
<div> * </div>
<div> */</div>
<div>public LetterGeneratorBIRTImpl() {</div>
<div>super();</div>
<div>}</div>
<div> </div>
<div>public void initEngine() throws LetterGeneratorException {</div>
<div>try {</div>
<div>log.debug("BIRT Home: " + birtHome);</div>
<div>log.debug("BirtLogHome: " + birtLogHome);</div>
<div> </div>
<div>config = new EngineConfig();</div>
<div>config.setEngineHome(birtHome);</div>
<div>//<span> </span>config.setBIRTHome(birtHome);</div>
<div>config.setLogConfig(birtLogHome, java.util.logging.Level.FINEST);</div>
<div>Platform.startup( config );</div>
<div> </div>
<div>IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);</div>
<div>engine = factory.createReportEngine(config);</div>
<div>engine.changeLogLevel( Level.WARNING );</div>
<div>} catch (BirtException e) {</div>
<div>throw new LetterGeneratorException(e.toString(), e);</div>
<div>}</div>
<div>}</div>
<div> </div>
<div>
@SuppressWarnings("
;unchecked")</div>
<div>public void executeReport(String format, InputStream template,</div>
<div>InputStream data, OutputStream result,</div>
<div>Map<String, Object> parameters) throws LetterGeneratorException {</div>
<div>try {</div>
<div>String reportFilePath="C:\\logfile\\LetterDesigns\\test.rptdesign";</div>
<div>IReportRunnable design = engine.openReportDesign(reportFilePath); </div>
<div> </div>
<div>IRunAndRenderTask task = engine.createRunAndRenderTask(design);</div>
<div> </div>
<div>if (parameters != null && parameters.size() > 0) {</div>
<div>for (String key : parameters.keySet())</div>
<div>task.setParameterValue(key, parameters.get(key));</div>
<div>task.validateParameters();</div>
<div>}</div>
<div> </div>
<div>RenderOption options = null;</div>
<div> </div>
<div>if (format.compareToIgnoreCase("PDF") == 0)</div>
<div>options = RenderPDF();</div>
<div>else if (format.compareToIgnoreCase("HTML") == 0)</div>
<div>options = RenderHTML();</div>
<div>else</div>
<div>throw new LetterGeneratorException("Unsupported format "</div>
<div>+ format);</div>
<div> </div>
<div>options.setOutputStream(result);</div>
<div>task.setRenderOption(options);</div>
<div><span style="color:#ff0000;"><u><strong>task.run(); // this is where exception : copied below</strong></u></span></div>
<div>task.close();</div>
<div>}</div>
<div>catch (Exception ex) {</div>
<div>log.error(ex.toString(), ex);</div>
<div>throw new LetterGeneratorException(ex.toString(), ex);</div>
<div>}</div>
<div> </div>
<div>engine.destroy();</div>
<div>Platform.shutdown();</div>
<div>RegistryProviderFactory.releaseDefault();</div>
<div> </div>
<div>}</div>
<div> </div>
<div>/**</div>
<div>* Setup to render PDF</div>
<div>* </div>
<div>*
@return
Answers a PDFRenderOption</div>
<div>*/</div>
<div>protected RenderOption RenderPDF() {</div>
<div>PDFRenderOption options = new PDFRenderOption();</div>
<div>options.setOutputFormat("pdf");</div>
<div>return options;</div>
<div>}</div>
<div> </div>
<div>/**</div>
<div>* Setup to render HTML</div>
<div>* </div>
<div>*
@return
Answer an HTMLRenderOption</div>
<div>*/</div>
<div>protected RenderOption RenderHTML() {</div>
<div>HTMLRenderOption options = new HTMLRenderOption();</div>
<div>options.setOutputFormat("html");</div>
<div>options.setHtmlRtLFlag(false);</div>
<div>options.setEmbeddable(true);</div>
<div>if (this.htmlImgHome != null && htmlImgHome.length() > 0)</div>
<div>options.setImageDirectory(this.htmlImgHome);</div>
<div>return options;</div>
<div>}</div>
<div> </div>
<div>}</div>
<div> </div>
<div>Exception:</div>
<div>
<div>**************************************</div>
<div>javax.servlet.ServletException: Internal error: com.birt.letters.LetterGeneratorException: org.eclipse.birt.report.engine.api.EngineException: Error happened while running the report.</div>
<div>at com.birt.servlet.PdfPrintLetters.generateLetter(PdfPrintLetters.java:414)</div>
<div>at com.birt.servlet.PdfPrintLetters.htmlDecodeResponse(PdfPrintLetters.java:334)</div>
<div>at com.birt.servlet.PdfPrintLetters.performTask(PdfPrintLetters.java:200)</div>
<div>at com.birt.servlet.PdfPrintLetters.doPost(PdfPrintLetters.java:87)</div>
<div>at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)</div>
<div>at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)</div>
<div>at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)</div>
<div>at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)</div>
<div>at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)</div>
<div>at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)</div>
<div>at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)</div>
<div>at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)</div>
<div>at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)</div>
<div>at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)</div>
<div>at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:881)</div>
<div>at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:674)</div>
<div>at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:541)</div>
<div>at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)</div>
<div>at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)</div>
<div>at java.lang.Thread.run(Thread.java:662)</div>
</div>