Error: net.sf.jasperreports.engine.JRException:


Hello, I am new to Jasper Reports and I am not sure where to store my ".jrxml" and ".jasper" files.

In my project, I have stored all my files in the src file folder, including the ".jrxml" and ".jasper" files but i receive an exception.

Can someone please tell/explain what i could be doing wrong and a solution for it, also where to store my files.

thank you

My code snippet is as follows :


 try {
            Connection con =DriverManager.getConnection("jdbc:sqlserver://localhost;" +
                    "instanceName=SQLEXPRESS2008;databaseName=OMA2008_DB;", "sa", "admin2008");
             JasperReport jasperReport =
             JasperPrint print = JasperFillManager.fillReport(jasperReport, parameter, con);
             JRViewer viewer = new JRViewer(print);
            Container c = getContentPane();
            c.setLayout(new BorderLayout());
         } catch (ClassNotFoundException cnfe) {
            System.out.println("Error: " + cnfe.toString());
         } catch(SQLException sqle) {
             System.out.println("Error: " + sqle.toString());
         } catch(JRException jre) {
             System.out.println("Error: " + jre.toString());
         } catch (JRRuntimeException e) {
             System.out.println("Error: " + e.toString());
Zweli's picture
Joined: Mar 25 2011 - 1:05am
Last seen: 1 year 4 months ago

2 Answers:


First, it's hard to find a situation where makes sense to compile a report (jrxml) file in your running application, and it seems your application have no need for this. You should keep the 'jrxml' files as part of your project, but only include the 'jasper' into the classpath, as it is already compiled and ready to use.

As an example, in my project I keep the 'jasper' files into a 'resources' source folder, which will be included in my packaged application, so it can be easily loaded. The snippet below should make it clearer.

So, put the 'jasper' files in your application classpath, and leave the source files (jrxml) out, as they will be useless for your running application.

String reportPath = "/com/company/reports/myreport.jasper";
InputStream reportStream = MyReportService.class.getResourceAsStream(reportPath);
if (reportStream == null) {
    throw new SomeException("Report not found!");
JasperPrint print = JasperFillManager.fillReport(reportStream, parameters, dataSoruce);

Post Edited by mdrg at 03/25/2011 16:40
mdrg's picture
Joined: Feb 18 2011 - 11:14am
Last seen: 9 years 1 week ago

hi...i have a problem that is where to store jrxmls& jaspers in our running application...from the above discussed topics u asked to save only i created a package in src and kept .jasper  files in it...but i got file not found exception.

should we change default expression in jrxmls also?

if we have to change how and where we have to change it?

initially i stored my jrxmls&.jasper in jasperreports folder in c drive.

please do help...its really important and urgent....

thanks in advance...

jasti's picture
Joined: Jun 10 2012 - 9:19pm
Last seen: 5 years 5 months ago