manjesh Posted July 27, 2007 Share Posted July 27, 2007 Hi, I am trying to compile a JRXML file to a .jasper file inside my webapp(here: MyWebApp) sitting inside an EAR file. I am trying the following API. JasperCompileManager.compileReportToFile("MyWebApp/jasper/sampleReport.jrxml","MyWebApp/jasper/sampleReport.jasper"); but for whatever reason I keep getting the error message saying 11:43:35,843 ERROR [sTDERR] net.sf.jasperreports.engine.JRException: java.io.FileNotFoundException: MyWebAppjaspersampleReport.jrxml (The system cannot find the path specified)11:43:35,843 ERROR [sTDERR] at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:172)11:43:35,843 ERROR [sTDERR] at net.sf.jasperreports.engine.xml.JRXmlLoader.load(JRXmlLoader.java:152)11:43:35,843 ERROR [sTDERR] at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:108)11:43:35,843 ERROR [sTDERR] at edu.utsouthwestern.jee5projweb.action.JasperReportsAction.execute(JasperReportsAction.java:40)11:43:35,843 ERROR [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)11:43:35,843 ERROR [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [/quote any idea how to get around this problem? Link to comment Share on other sites More sharing options...
lukkumar Posted July 28, 2007 Share Posted July 28, 2007 You need to specify to the jasper classpath where your file is located so try this one and see if it is working... System.setProperty("jasper.reports.compile.class.path",context.getRealPath("/WEB-INF/lib/jasperreports-1.3.4.jar")+ System.getProperty("path.separator")+ context.getRealPath("/WEB-INF/classes/"));//Specify a default folder for storing//compiled XML templatesSystem.setProperty("jasper.reports.compile.temp",context.getRealPath("/reports/")); In this example I have placed my jrxml files in the reports directory. Execute these statements before compiling and it will work. Link to comment Share on other sites More sharing options...
giroe Posted July 30, 2007 Share Posted July 30, 2007 Euhm, I think you are making it a bit too difficult.His path to his .jrxml file just seems to be incorrect.Just try to put to complete path to test it, so instead of "MyWebApp/jasper/sampleReport.jrxml" type: c:/.../.../.../.../sapleReport.jrxml(if you want to make the path more dynamical you can use: String path=context.getRealPath("/WEB-INF/path_to_reportmap"); like lukkumar said. than the string path will be: c:/your path to your webapp/WEB-INF/path_to_reportmap)Post edited by: giroe, at: 2007/07/30 10:21 Link to comment Share on other sites More sharing options...
Teodor Danciu Posted July 30, 2007 Share Posted July 30, 2007 Hi, First of all, you should make sure you need to compile report templates at runtime.Since you've put the JRXML file in an EAR file, it is obvious you don't need to compile report templates at runtime.Your JRXML is static. It does not change at runtime. So why don't you compile it when you build your EAR and put only the compiler *.jasper file there????Only when we deal with dynamic report templates (templates change at runtime) we need to compile them. And even if you do need to compile JRXML at runtime, you have to make sure you can locate the file on disk. This is not related to JasperReports whatsoever. It is a FileNotFound exception in your case.Note that you don't need to configure any system property in order to compile report templates. You only need to make sure that the jdt-compiler.jar file is in the classpath of your application. You can find it in the /lib directory of the JasperReports project distribution. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
lukkumar Posted July 30, 2007 Share Posted July 30, 2007 The information that I have provided in my previous post was from the following article from IBM http://www-128.ibm.com/developerworks/websphere/library/techarticles/0411_olivieri/0411_olivieri.html#download I have done the above approach only once during the instance creation, since compilation to .jasper is needed only once. Thanks. Link to comment Share on other sites More sharing options...
lukkumar Posted July 30, 2007 Share Posted July 30, 2007 The other approach would be to provide the full path to the .jrxml file but, I think the approach to the one in paper is for dynamic creation... Thanks.Post edited by: lukkumar, at: 2007/07/30 16:24 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