zawmn83 Posted September 14, 2009 Share Posted September 14, 2009 HiFollowings is my server configurationCentos 5.3Tomcat 5Open JDK Runtime Evnironment (build 1.6.0-b09)PHP 5.3.0Apache version 2.2.3 php-java-bridge_5.4.4.2jasperreports-3.5.3When I tested BarbecueReport.jrxml from a jsp file, it is working well.I'm trying to use jasper report from php according to http://www.rjohnson.id.au/wordpress/2007/10/27/bullet-proof-jasper-reports-and-phpBut when I try BarbecueReport.jrxml from php, I got the following two error one for exportReportToPdfFile and another for exportReportToHtmlFile.I note that only files with zero byte are output to /var/www/html/mysuite/tmp/.I tested this php files in local centos linux server, it is working well.Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: Invoke failed: [[c:JasperExportManager]]->exportReportToPdfFile((o:JasperPrint)[o:JasperPrint], (o:String)[o:String]). Cause: net.sf.jasperreports.engine.JRException: Error trying to export to file : /var/www/html/mysuite/tmp/jasperNO8iz5 VM: 1.6.0@http://java.sun.com/" at: #-11 net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:388) #-10 net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfFile(JasperExportManager.java:126) #-9 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) #-8 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) #-7 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) #-6 java.lang.reflect.Method.invoke(Method.java:616) #-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1077) #-4 php.java.bridge.Request.handleRequest(Request.java:414) #-3 php.java.bridge.Request.handleRequests(Request.java:490) #-2 php.java.bridge.http.ContextRunne in http://127.0.0.1:8080/JavaBridge/java/Java.inc on line 215 Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: Invoke failed: [[c:JasperExportManager]]->exportReportToHtmlFile((o:JasperPrint)[o:JasperPrint], (o:String)[o:String]). Cause: net.sf.jasperreports.engine.JRException: Error creating to file writer : textquestion VM: 1.6.0@http://java.sun.com/" at: #-11 net.sf.jasperreports.engine.export.JRHtmlExporter.exportReport(JRHtmlExporter.java:480) #-10 net.sf.jasperreports.engine.JasperExportManager.exportReportToHtmlFile(JasperExportManager.java:440) #-9 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) #-8 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) #-7 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) #-6 java.lang.reflect.Method.invoke(Method.java:616) #-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1077) #-4 php.java.bridge.Request.handleRequest(Request.java:414) #-3 php.java.bridge.Request.handleRequests(Request.java:490) #-2 php.java.bridge.http.ContextRunner.run(ContextRunner.jav in http://127.0.0.1:8080/JavaBridge/java/Java.inc on line 215 What wrong with me?Thanks in advance Link to comment Share on other sites More sharing options...
zawmn83 Posted September 15, 2009 Author Share Posted September 15, 2009 Hi I solved my issue.It is permission problem between apache and tomcat users.The following is my code that raise error. I created unique temp file in php by using tempnam function.In this case this new file is readonly to others users (including tomcat) even I set permission 777 to parent tmp folder.So tomcat can't write file in exportReportToPdfFile function.$outputPath = tempnam(realpath("tmp"), "jasper"); //generate unique temp file name $exportManager->exportReportToPdfFile($jasperPrint, $outputPath);I insert chmod in code and it is solved problem.$outputPath = tempnam(realpath("tmp"), "jasper"); //generate unique temp file name chmod($outputPath, 0766); //allow tomcat to write permission$exportManager->exportReportToPdfFile($jasperPrint, $outputPath);But I got another problem, when I clear tmp files from apache.I want to delete generated tmp file after viewing report.I think it is ok to delete generated pdf file and html file because their permission are 0766 and can be read/write from both apache and tomcat. But for the files under tmpfilename.html_files folder, they are belong to tomcat. And readonly to apache and I can't delete these files from apache.Is there any jasper build-in function or parameter to set output tmpfilename.html_files folder and subfiles permission?Thanks Link to comment Share on other sites More sharing options...
Teodor Danciu Posted September 29, 2009 Share Posted September 29, 2009 Hi, You don't need to work with temporary files on disk when you export. The report output can be delivered directly to the browser by streaming it to the response output stream. Check the /demo/samples/webapp in the JR project for more details. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now