java.lang.NullPointerException in JasperPrint with JasperReport

0

Hello!

I have a Jasper document / report that I want to access and then print.

For this I enter the following code:

//Creo la variable que contendrá el reporte
    JasperReport miReporte = (JasperReport) JRLoader.loadObject("src/REPORTE/MotivosDebitos.jasper");

    //Creo mi lista con los parametros a enviar
    Map misParametros = new HashMap();

    //Ingreso los parametros necesarios
    misParametros.put("parametro1", parametro1);
    misParametros.put("parametro2", parametro2);
    misParametros.put("parametro3", parametro3);
    misParametros.put("parametro4", parametro4);

    //Establezco la conexion
    Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5433/SisForPres","postgres","postgres");

    //Preparo para mostrar
    JasperPrint miJasperPrint = JasperFillManager.fillReport(miReporte, misParametros, conn);

    JasperViewer miJasperViewer = new JasperViewer(miJasperPrint, false);

    //Le doy un titulo al documento
    miJasperViewer.setTitle("UnTitulo");

    //Lo hago visible
    miJasperViewer.setVisible(true);

    //Cierro la conexion
    conn.close();

Well, now the problem is this: when I execute the code and this method is called, it throws the following exception:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at net.sf.jasperreports.engine.fill.JRFillTextField.getFormat(JRFillTextField.java:706)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:394)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:368)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:499)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:326)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:262)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:946)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)

More specifically on the following line:

//Preparo para mostrar
    JasperPrint miJasperPrint = JasperFillManager.fillReport(miReporte, misParametros, conn);

I use iReport v5.5.0.

Would someone give me a hand here?

    
asked by Ramiro Romero 02.05.2018 в 15:39
source

0 answers