title: Jasper Report : "Document has no pages"
body: <p>I have a problem when I run this code. I get always this message : "Document has no pages" with a blank page in the pdf file .</p>
  
  <p>Note: I'm using NetBeans IDE 7.2 Beta.</p>
  
  <p>Jar files imported are:</p>
  
  <ul>
  <li>com.lowagie.text-2.1.7.jar</li>
  <li>commons-beanutils-1.5.jar</li>
  <li>commons-collections-2.1.jar</li>
  <li>commons-digester-2.1.jar</li>
  <li>commons-javaflow.jar</li>
  <li>commons-logging-1.3.jar</li>
  <li>jasperreports-5.5.1.jar</li>
  <li>javax.servlet.jar</li>
  </ul>
  
  <p>I need your help,please.</p>
  
  <p>this is my code :</p>
  
  <pre><code>import java.math.BigDecimal;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.util.Currency;
  import java.util.HashMap;
  import javax.swing.JFrame;
  import net.sf.jasperreports.engine.JRException;
  import net.sf.jasperreports.engine.JasperCompileManager;
  import net.sf.jasperreports.engine.JasperExportManager;
  import net.sf.jasperreports.engine.JasperFillManager;
  import net.sf.jasperreports.engine.JasperPrint;
  import net.sf.jasperreports.engine.JasperReport;
  import net.sf.jasperreports.swing.JRViewer;
  
  
  public class Report extends JFrame{
  
  
     public Report(String month,int year){
  
                      try{
                          //load the driver
                  Class.forName("com.mysql.jdbc.Driver");
                  String url="jdbc:mysql://localhost:3306/motor";
                  String user="root";
                  String pass="";
  
                  Connection cn=DriverManager.getConnection(url,user,pass);
                  System.out.println("connected in report");
                  PreparedStatement ps = cn.prepareStatement("select number,title,name,ikar,echtirak,price,tarakom from users order by number asc");
                  ResultSet rs;
                  rs=ps.executeQuery();
  
                   JasperPrint jasperPrint=null;
                 HashMap&lt;String, Object&gt; mapParameters = new HashMap &lt;String, Object&gt;();
  
               // jrxml compiling process
  
             JasperReport jasperReport = JasperCompileManager.compileReport("C:/Users/user/Documents/NetBeansProjects/MotorApp/MyReports/motorReport.jrxml");
             int i=1;
                  while(rs.next()){
  
                   mapParameters.put("Name", rs.getString("title")+" "+rs.getString("name"));
                   mapParameters.put("Number",rs.getString("number"));
                   mapParameters.put("Ikar",rs.getString("ikar"));
                   mapParameters.put("Amperage",rs.getString("echtirak")+" A");
                   mapParameters.put("tarakom",rs.getString("tarakom")+" $");
                   mapParameters.put("monthPrice",rs.getString("price")+" $");
  
                   Integer total=Integer.parseInt(rs.getString("price"))+Integer.parseInt(rs.getString("tarakom"));
                   mapParameters.put("totalPrice",total+" $");
                   mapParameters.put("monthYear",year+" "+month);
  
  
                   try{
  
                  System.out.println("Filling report...");
                  jasperPrint = JasperFillManager.fillReport(jasperReport, mapParameters,cn);
                  JRViewer viewer = new JRViewer(jasperPrint);
                   System.out.println("Done!");
                  JasperExportManager.exportReportToPdfFile(jasperPrint,"C:/Users/user/Desktop/"+month+" "+year+".pdf");
  
                   }catch(JRException elle){
                       System.out.println(elle.getMessage());
                   }
  
                   }
  
               }catch(Exception ev){
                   System.out.println(ev.getMessage());
               }
  
     }
  
  
  }
  </code></pre>
  
  <p>I truly appreciate your help.</p>