Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Saving birt output report on server side(Saving birt output report on server side)
Saving birt output report on server side [message #649680] Thu, 20 January 2011 04:55 Go to next message
JIE is currently offline JIE
Messages: 4
Registered: January 2011
Junior Member
Hi all,

I'm using birt 2.3.2 to generate PDF report in the Java web application.

I could view the the output PDF in the firefox now, by clicking a button which will forward the request to a JSP page, in which the 'birt:viewer' object is defined.

But I also want to save the PDF into the disk of server side.

I'm thinking of writing a Java class extending ReportEventAdapter(Using afterRender event) and binding it with .rptdesign. But it seems no way to get content of report in java class...

Does anybody know how to do that? Or another solution to save the PDF?

Any information will be appreciated.

Thanks in advance!
Re: Saving birt output report on server side [message #649841 is a reply to message #649680] Thu, 20 January 2011 12:24 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

You can create either a run task or render task in the after render
event handler to do what you want. You could enter a script like this
to do just a render (note example is in JavaScript but could be done in
Java).

rptdoc =
reportContext.getHttpServletRequest().getAttribute("attributeBean ").getReportDocumentName();

importPackage(Packages.org.eclipse.birt.report.engine.api);
var re = reportContext.getReportRunnable().getReportEngine();
var mdocument = re.openReportDocument(rptdoc);
var options = new PDFRenderOption();
options.setOutputFormat("pdf");
options.setOutputFileName("c:/test/mytest.pdf");

var ntask = re.createRenderTask(mdocument);
ntask.setRenderOption(options);
ntask.render();
ntask.close();

This code has no error checking in it. You also may want to put a check
in to see if you are in the designer and not run the code if you are.

reportContext.getHttpServletRequest().getAttribute("attributeBean ").isDesigner();

Here is an example of doing a run and render task:
importPackage(Packages.org.eclipse.birt.report.engine.api);
var re = reportContext.getReportRunnable().getReportEngine();
var des = re.openReportDesign("c:/xfer/burstdetail.rptdesign");

var ntask = re.createRunAndRenderTask(des);
ntask.setParameterValue("CustomerNumber",
this.getRowData().getColumnValue(0).toString() );
var options = new PDFRenderOption();
var outputfile = "c:/temp/test" + this.getRowData().getColumnValue(0) +
".pdf";
options.setOutputFileName(outputfile);
options.setOutputFormat("pdf");
ntask.setRenderOption(options);
ntask.run();
ntask.close();

Jason

On 1/20/2011 4:55 AM, JIE wrote:
> Hi all,
>
> I'm using birt 2.3.2 to generate PDF report in the Java web application.
> I could view the the output PDF in the firefox now, by clicking a button
> which will forward the request to a JSP page, in which the 'birt:viewer'
> object is defined.
>
> But I also want to save the PDF into the disk of server side.
>
> I'm thinking of writing a Java class extending ReportEventAdapter(Using
> afterRender event) and binding it with .rptdesign. But it seems no way
> to get content of report in java class...
>
> Does anybody know how to do that? Or another solution to save the PDF?
>
> Any information will be appreciated.
>
> Thanks in advance!
Re: Saving birt output report on server side [message #649942 is a reply to message #649841] Fri, 21 January 2011 01:19 Go to previous messageGo to next message
JIE is currently offline JIE
Messages: 4
Registered: January 2011
Junior Member
Hi Jason,

Thank you very much for your help.

I can do it in Java now Smile

Re: Saving birt output report on server side [message #649979 is a reply to message #649841] Fri, 21 January 2011 04:45 Go to previous messageGo to next message
JIE is currently offline JIE
Messages: 4
Registered: January 2011
Junior Member
I've tried the Javascript and it generated the pdf in the disk.

But the pdf cannot be opened (The file is already open or in use by another application.)

Only when the request is changed(I click somewhere else in the application) or shut down the server, can it open.

Do you know why?


Jason Weathersby wrote on Thu, 20 January 2011 12:24
You can create either a run task or render task in the after render
event handler to do what you want. You could enter a script like this
to do just a render (note example is in JavaScript but could be done in
Java).

rptdoc =
reportContext.getHttpServletRequest().getAttribute("attributeBean ").getReportDocumentName();

importPackage(Packages.org.eclipse.birt.report.engine.api);
var re = reportContext.getReportRunnable().getReportEngine();
var mdocument = re.openReportDocument(rptdoc);
var options = new PDFRenderOption();
options.setOutputFormat("pdf");
options.setOutputFileName("c:/test/mytest.pdf");

var ntask = re.createRenderTask(mdocument);
ntask.setRenderOption(options);
ntask.render();
ntask.close();

This code has no error checking in it. You also may want to put a check
in to see if you are in the designer and not run the code if you are.

reportContext.getHttpServletRequest().getAttribute("attributeBean ").isDesigner();

Re: Saving birt output report on server side [message #650093 is a reply to message #649979] Fri, 21 January 2011 11:55 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Try adding

mdocument.close();
after you close the task.

Jason

On 1/21/2011 4:45 AM, JIE wrote:
> I've tried the Javascript and it generated the pdf in the disk.
>
> But the pdf cannot be opened (The file is already open or in use by
> another application.)
>
> Only when the request is changed(I click somewhere else in the
> application) or shut down the server, can it open.
>
> Do you know why?
>
>
> Jason Weathersby wrote on Thu, 20 January 2011 12:24
>> You can create either a run task or render task in the after render
>> event handler to do what you want. You could enter a script like this
>> to do just a render (note example is in JavaScript but could be done
>> in Java).
>>
>> rptdoc =
>> reportContext.getHttpServletRequest().getAttribute("attributeBean
>> ").getReportDocumentName();
>>
>> importPackage(Packages.org.eclipse.birt.report.engine.api);
>> var re = reportContext.getReportRunnable().getReportEngine();
>> var mdocument = re.openReportDocument(rptdoc);
>> var options = new PDFRenderOption();
>> options.setOutputFormat("pdf");
>> options.setOutputFileName("c:/test/mytest.pdf");
>>
>> var ntask = re.createRenderTask(mdocument);
>> ntask.setRenderOption(options);
>> ntask.render();
>> ntask.close();
>>
>> This code has no error checking in it. You also may want to put a
>> check in to see if you are in the designer and not run the code if you
>> are.
>>
>> reportContext.getHttpServletRequest().getAttribute("attributeBean
>> ").isDesigner();
>
>
Re: Saving birt output report on server side [message #650260 is a reply to message #650093] Sun, 23 January 2011 21:26 Go to previous messageGo to next message
JIE is currently offline JIE
Messages: 4
Registered: January 2011
Junior Member
Still not working...
Re: Saving birt output report on server side [message #650390 is a reply to message #650260] Mon, 24 January 2011 12:13 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Try this (again with no error checking):

mmap =
reportContext.getHttpServletRequest().getAttribute("attributeBean ").getModuleOptions();
rptdoc =
reportContext.getHttpServletRequest().getAttribute("attributeBean ").getReportDocumentName();

importPackage(Packages.org.eclipse.birt.report.engine.api);
importPackage(Packages.java.io)
var re = reportContext.getReportRunnable().getReportEngine();
var mdocument = re.openReportDocument(null,rptdoc, mmap);
var options = new PDFRenderOption();
baos = new ByteArrayOutputStream();
options.setOutputFormat("pdf");
options.setOutputStream(baos);

var ntask = re.createRenderTask(mdocument);
ntask.setRenderOption(options);
ntask.render();
ntask.close();
mdocument.close();

fout = new FileOutputStream("c:/test/myreport.pdf");
fout.write(baos.toByteArray());
fout.flush()
fout.close();


Jason

On 1/23/2011 9:26 PM, JIE wrote:
> Still not working...
Re: Saving birt output report on server side [message #696831 is a reply to message #650390] Thu, 14 July 2011 18:42 Go to previous messageGo to next message
Magg  is currently offline Magg
Messages: 7
Registered: July 2011
Junior Member
Hi JIE and Jason. I need to implement this approach in my birt reports. JIE, do you solved the problem with the generated pdf: "The file is already open or in use by another application"? And what other improves do you maked to the code? Thanks for your tips and code, I´m novice with birt and don´t know how to begin, but your comments are very helpful.
Re: Saving birt output report on server side [message #698008 is a reply to message #696831] Mon, 18 July 2011 11:16 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

If you are using event scripting to do this look at the attached example
which does a second render in the beforeRendering event.

Jason


On 7/14/2011 6:42 PM, Magg wrote:
> Hi JIE and Jason. I need to implement this approach in my birt reports.
> JIE, do you solved the problem with the generated pdf: "The file is
> already open or in use by another application"? And what other improves
> do you maked to the code? Thanks for your tips and code, I´m novice with
> birt and don´t know how to begin, but your comments are very helpful.
Re: Saving birt output report on server side [message #701934 is a reply to message #698008] Mon, 25 July 2011 14:46 Go to previous messageGo to next message
Magg  is currently offline Magg
Messages: 7
Registered: July 2011
Junior Member
Thanks, very much for the .rptdesign file and the tips. I will try to implement that in my reports. Best regards!!
Re: Saving birt output report on server side [message #717920 is a reply to message #701934] Mon, 22 August 2011 13:47 Go to previous messageGo to next message
Magg  is currently offline Magg
Messages: 7
Registered: July 2011
Junior Member
Hello. One more time I need your valuable help. I can already generate my pdf´s, and make the folders if not exists, and personalize the name of the pdf with custom params. But also need to register the name of the resultant document in my DB. I have been looking for tips in the forum, but no entry talk about execute sql in a beforeRender script, or any other event. Do you know any link in the forum where discusses about that?? Sorry for my very bad english. Thanks in advance.
Re: Saving birt output report on server side [message #717940 is a reply to message #717920] Mon, 22 August 2011 14:30 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

BIRT does not have any script functions that specifically write back to
a database, but you could always write your own class that inserts into
a db and call it from BIRT event handlers.

Jason

On 8/22/2011 1:47 PM, Magg wrote:
> Hello. One more time I need your valuable help. I can already generate
> my pdf´s, and make the folders if not exists, and personalize the name
> of the pdf with custom params. But also need to register the name of the
> resultant document in my DB. I have been looking for tips in the forum,
> but no entry talk about execute sql in a beforeRender script, or any
> other event. Do you know any link in the forum where discusses about
> that?? Sorry for my very bad english. Thanks in advance.
Re: Saving birt output report on server side [message #1060373 is a reply to message #698008] Fri, 24 May 2013 06:50 Go to previous messageGo to next message
Shashank kumar is currently offline Shashank kumar
Messages: 3
Registered: May 2013
Junior Member
Hi Jason

First of All thanks for the script in rptdesign file.

I tried it works fine when using in designer. but when running the report using web application ,can see files get created but with no content and been in use by other service.

how to solve this issue?? any help is appreciated..

I am using given script in beforeRender method. and get this exception


-----------------

Unhandled exception when executing script.
Error.UnhandledScriptError ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: Unhandled exception when executing script. at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:199) at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:176) at org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleBeforeRender(ReportScriptExecutor.java:123) at org.eclipse.birt.report.engine.api.impl.EngineTask.startRender(EngineTask.java:1376) at org.eclipse.birt.report.engine.api.impl.RenderTask$PageRangeRender.render(RenderTask.java:510) at org.eclipse.birt.report.engine.api.impl.RenderTask.render(RenderTask.java:209) at org.eclipse.birt.report.service.ReportEngineService.renderReport(ReportEngineService.java:1444) at org.eclipse.birt.report.service.BirtViewerReportService.getPage(BirtViewerReportService.java:194) at org.eclipse.birt.report.service.actionhandler.AbstractGetPageActionHandler.doExecution(AbstractGetPageActionHandler.java:238) at org.eclipse.birt.report.service.actionhandler.AbstractGetPageActionHandler.__execute(AbstractGetPageActionHandler.java:105) at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90) at org.eclipse.birt.report.soapengine.processor.AbstractBaseDocumentProcessor.__executeAction(AbstractBaseDocumentProcessor.java:47) at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.executeAction(AbstractBaseComponentProcessor.java:143) at org.eclipse.birt.report.soapengine.processor.BirtDocumentProcessor.handleGetPage(BirtDocumentProcessor.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.process(AbstractBaseComponentProcessor.java:112) at org.eclipse.birt.report.soapengine.endpoint.BirtSoapBindingImpl.getUpdatedObjects(BirtSoapBindingImpl.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397) at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186) at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454) at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281) at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699) at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.doPost(BirtSoapMessageDispatcherServlet.java:265) at javax.servlet.http.HttpServlet.service(HttpServlet.java:616) at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.service(BirtSoapMessageDispatcherServlet.java:122) at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180) at org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90) at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111) at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:59) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:269) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428) at org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:677) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568) at org.mortbay.http.HttpContext.handle(HttpContext.java:1530) at org.mortbay.http.HttpContext.handle(HttpContext.java:1482) at org.mortbay.http.HttpServer.service(HttpServer.java:909) at org.mortbay.http.HttpConnection.service(HttpConnection.java:820) at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986) at org.mortbay.http.HttpConnection.handle(HttpConnection.java:837) at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245) at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357) at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)Caused by: org.eclipse.birt.core.exception.CoreException: There are errors evaluating script "mmap = reportContext.getHttpServletRequest().getAttribute("attributeBean").getModuleOptions();rptdoc = reportContext.getHttpServletRequest().getAttribute("attributeBean").getReportDocumentName();importPackage(Packages.org.eclipse.birt.report.engine.api);importPackage(Packages.java.io)var re = reportContext.getReportRunnable().getReportEngine();var mdocument = re.openReportDocument(null,rptdoc, mmap); var options = new PDFRenderOption();baos = new ByteArrayOutputStream(); options.setOutputFormat("pdf");options.setOutputStream(baos);var ntask = re.createRenderTask(mdocument); ntask.setRenderOption(options);ntask.render();ntask.close();mdocument.close();fout = new FileOutputStream("c:/test/myreport1.pdf"); fout.write(baos.toByteArray());fout.flush()fout.close(); ":The choice of Java constructor write matching JavaScript argument types ([B) is ambiguous; candidate constructors are: void write(int) void write(byte[]) (/report/method[@name="beforeRender"]#20). at org.eclipse.birt.core.script.ScriptContext.eval(ScriptContext.java:307) at org.eclipse.birt.core.script.ScriptContext.eval(ScriptContext.java:335) at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:665) at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleJSInternal(ScriptExecutor.java:60) at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleJS(ScriptExecutor.java:47) at org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleBeforeRender(ReportScriptExecutor.java:115) ... 53 moreCaused by: org.mozilla.javascript.EvaluatorException: The choice of Java constructor write matching JavaScript argument types ([B) is ambiguous; candidate constructors are: void write(int) void write(byte[]) (/report/method[@name="beforeRender"]#20) at org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1030) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1086) at org.mozilla.javascript.Context.reportRuntimeError3(Context.java:1064) at org.mozilla.javascript.NativeJavaMethod.findFunction(NativeJavaMethod.java:442) at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:157) at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66) at org.mozilla.javascript.gen.c725._c0(/report/method[@name="beforeRender"]:20) at org.mozilla.javascript.gen.c725.call(/report/method[@name="beforeRender"]) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834) at org.mozilla.javascript.gen.c725.call(/report/method[@name="beforeRender"]) at org.mozilla.javascript.gen.c725.exec(/report/method[@name="beforeRender"]) at org.eclipse.birt.core.script.ScriptContext.eval(ScriptContext.java:302) ... 58 more
Re: Saving birt output report on server side [message #1060483 is a reply to message #698008] Sat, 25 May 2013 03:27 Go to previous messageGo to next message
Shashank kumar is currently offline Shashank kumar
Messages: 3
Registered: May 2013
Junior Member
Hi

This is working in birt 3.7.1 but not in 2.3.2 .In 2.3.2 give exception
given below..

org.eclipse.birt.report.engine.api.EngineException: Unhandled exception when executing script. at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:199)
at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:176) at
org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleBeforeRender(ReportScriptExecutor.java:123) at
org.eclipse.birt.report.engine.api.impl.EngineTask.startRender(EngineTask.java:1376) at org.eclipse.birt.report.engine.api.impl.RenderTask$PageRangeRender.render(RenderTask.java:510) at
org.eclipse.birt.report.engine.api.impl.RenderTask.render(RenderTask.java:209) at org.eclipse.birt.report.service.ReportEngineService.renderReport(ReportEngineService.java:1444) at
org.eclipse.birt.report.service.BirtViewerReportService.getPage(BirtViewerReportService.java:194) at
org.eclipse.birt.report.service.actionhandler.AbstractGetPageActionHandler.doExecution(AbstractGetPageActionHandler.java:238) at
org.eclipse.birt.report.service.actionhandler.AbstractGetPageActionHandler.__execute(AbstractGetPageActionHandler.java:105) at
org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90) at
org.eclipse.birt.report.soapengine.processor.AbstractBaseDocumentProcessor.__executeAction(AbstractBaseDocumentProcessor.java:47) at
org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.executeAction(AbstractBaseComponentProcessor.java:143) at
org.eclipse.birt.report.soapengine.processor.BirtDocumentProcessor.handleGetPage(BirtDocumentProcessor.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at
java.lang.reflect.Method.invoke(Method.java:611) at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.process(AbstractBaseComponentProcessor.java:112) at
org.eclipse.birt.report.soapengine.endpoint.BirtSoapBindingImpl.getUpdatedObjects(BirtSoapBindingImpl.java:66) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at
java.lang.reflect.Method.invoke(Method.java:611) at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397) at
org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186) at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323) at
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at
org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454) at org.apache.axis.server.AxisServer.invoke(AxisServer.java:
281) at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699) at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.doPost(BirtSoapMessageDispatcherServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:616) at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.service(BirtSoapMessageDispatcherServlet.java:122) at
org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180) at
org.eclipse.equinox.http.servlet.internal.ServletRegistration.handleRequest(ServletRegistration.java:90) at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:111) at
org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:59) at javax.servlet.http.HttpServlet.service(HttpServlet.java:689) at
org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:269) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
at org.mortbay.jetty.servlet.ServletHandler.dispatch(ServletHandler.java:677) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568) at
org.mortbay.http.HttpContext.handle(HttpContext.java:1530) at org.mortbay.http.HttpContext.handle(HttpContext.java:1482) at org.mortbay.http.HttpServer.service(HttpServer.java:909) at
org.mortbay.http.HttpConnection.service(HttpConnection.java:820) at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986) at
org.mortbay.http.HttpConnection.handle(HttpConnection.java:837) at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:245) at
org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357) at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534) Caused by: org.eclipse.birt.core.exception.CoreException:
There are errors evaluating script "mmap = reportContext.getHttpServletRequest().getAttribute("attributeBean").getModuleOptions(); rptdoc =
reportContext.getHttpServletRequest().getAttribute("attributeBean").getReportDocumentName(); importPackage(Packages.org.eclipse.birt.report.engine.api); importPackage(Packages.java.io) var
re = reportContext.getReportRunnable().getReportEngine(); var mdocument = re.openReportDocument(null,rptdoc, mmap); var options = new PDFRenderOption(); baos = new
ByteArrayOutputStream(); options.setOutputFormat("xls"); options.setOutputStream(baos); var ntask = re.createRenderTask(mdocument); ntask.setRenderOption(options); ntask.render();
ntask.close(); mdocument.close(); fout = new FileOutputStream("c:/test/testLocale.xls"); fout.write(baos.toByteArray()); fout.flush() fout.close(); ": The choice of Java constructor write matching
JavaScript argument types ([B) is ambiguous; candidate constructors are: void write(int) void write(byte[]) (/report/method[@name="beforeRender"]#20). at
org.eclipse.birt.core.script.ScriptContext.eval(ScriptContext.java:307) at org.eclipse.birt.core.script.ScriptContext.eval(ScriptContext.java:335) at
org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:665) at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleJSInternal(ScriptExecutor.java:60)
at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleJS(ScriptExecutor.java:47) at
org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleBeforeRender(ReportScriptExecutor.java:115) ... 53 more Caused by: org.mozilla.javascript.EvaluatorException: The choice of
Java constructor write matching JavaScript argument types ([B) is ambiguous; candidate constructors are: void write(int) void write(byte[]) (/report/method[@name="beforeRender"]#20) at
org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109) at org.mozilla.javascript.Context.reportRuntimeError(Context.java:1030) at
org.mozilla.javascript.Context.reportRuntimeError(Context.java:1086) at org.mozilla.javascript.Context.reportRuntimeError3(Context.java:1064) at
org.mozilla.javascript.NativeJavaMethod.findFunction(NativeJavaMethod.java:442) at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:157) at
org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66) at org.mozilla.javascript.gen.c7._c0(/report/method[@name="beforeRender"]:20) at org.mozilla.javascript.gen.c7.call(/
report/method[@name="beforeRender"]) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
at org.mozilla.javascript.gen.c7.call(/report/method[@name="beforeRender"]) at org.mozilla.javascript.gen.c7.exec(/report/method[@name="beforeRender"]) at
org.eclipse.birt.core.script.ScriptContext.eval(ScriptContext.java:302) ... 58 more
any idea how to make it work in 2.3.2

Regards

[Updated on: Sat, 25 May 2013 03:28]

Report message to a moderator

Re: Saving birt output report on server side [message #1060486 is a reply to message #698008] Sat, 25 May 2013 04:09 Go to previous messageGo to next message
Shashank kumar is currently offline Shashank kumar
Messages: 3
Registered: May 2013
Junior Member
Hi Jason

does it work in birt 2.3.2 or not because when i am trying it getting exception,

and same error as file in use.

It seems some problem with script fout.write(baos.toByteArray());

Plz guide.

[Updated on: Sat, 25 May 2013 09:24]

Report message to a moderator

Re: Saving birt output report on server side [message #1061035 is a reply to message #1060486] Wed, 29 May 2013 11:47 Go to previous message
Michael Williams is currently offline Michael Williams
Messages: 1547
Registered: July 2009
Senior Member

Are you just using this exact report above in 2.3.2? Let me know. I'll test it out.

Michael

Add interactivity, scheduling, sharing, live Excel export, and JS integration to your BIRT app with the new, free BIRT server, BIRT iHub F-Type.
Previous Topic:Birt default Excel Emitter
Next Topic:Text Truncating and blank pages in BIRT
Goto Forum:
  


Current Time: Wed Jul 30 13:23:00 EDT 2014

Powered by FUDForum. Page generated in 0.02290 seconds