Jasper报道:找不到课堂错误

时间:2013-02-13 19:57:21

标签: java swing java-ee nullpointerexception jasper-reports

我正在尝试打印我的报告,但它没有进入jrviewer。 这是我得到的例外

  

线程“main”中的异常java.lang.NullPointerException at   net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:1034)     在   net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:1004)     在   net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)     在   net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:499)     在   net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:326)     在   net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:262)     在   net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)     在   net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:946)     在   net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845)     在   net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)     在   net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)     在   net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:247)     在Reports.ReportView。(ReportView.java:36)at   Main.main(Main.java:27)

这是我的代码: {

public class ReportView extends JFrame
{
    public ReportView(String fileName) throws Exception
    {
        this(fileName, null);
    }
    public ReportView(String fileName, HashMap para) throws Exception
    {
        super("ABC Solutions Employee/Project Management System (Report Viewer)");
        DBhandler db = new DBhandler();
        Connection con = db.getconnection();
        try
        {
            JasperPrint print = JasperFillManager.fillReport(fileName, para, con);
            JRViewer viewer = new JRViewer(print);
            Container c = getContentPane();
            c.add(viewer);            
        } 
        catch (JRException jRException)
        {

        }
        setBounds(10, 10, 1500, 1500);
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    }

}
}

2 个答案:

答案 0 :(得分:0)

不传递空值。如果您没有任何参数,请在将参数HashMap传递给Jasper之前将其实例化。即使它是空的:

   public ReportView(String fileName) throws Exception
   {
        this(fileName, new HashMap< String, String >() );
   }

答案 1 :(得分:0)

在Jasper-report服务器中,您无法在图表类别列中传递“null”值。