Why do I get java.lang.NullPointerException when java.lang.Class.isAssignableFrom (native method) when calling JasperFillManager?

JasperFillManager throws a null pointer exception when I pass the sql connection in its parameter, but it works fine when passing the JRResultSetDatasource.

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.fillColumnBand(JRVerticalFiller.java:2036) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:760) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:270) 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.JRFillSubreport.fillSubreport(JRFillSubreport.java:609) at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59) at net.sf.jasperreports.engine.fill.JRThreadSubreportRunner.run(JRThreadSubreportRunner.java:205) at java.lang.Thread.run(Unknown Source) 

when I pass the connection to fillReport it gives an exception.

 jasperPrint = JasperFillManager.fillReport(jasperReport, map, reportConnection); 

I also use subreport, so I am not using JRResultSetDatasource and not using a connection. I was just stuck in this note that when I pass the JRResultSetDatasource it works fine, and when I also pass the connection object in the HasMap parameter, it gives the same error as above.

+7
source share
4 answers

I just fixed this two minutes ago by updating the jar iReport file to the latest version

+8
source

Your jasper-designer and jar in your project must be the same version.

+4
source

The jar files in the lib project folder must match the iReport version. I had the same problem and it was resolved with the correct jar files. you can see the link below: http://sourceforge.net/projects/jasperreports/files/jasperreports/

+2
source

There is no need to replace the old .jar with the new .jar. If you have an option. Suppose you need to maintain an old jar, but it should work. Please use this.

The following code works in the higher version [Ex: 4.1.1] not in the older version [Ex: 3.7.6].

  <subreport> <reportElement positionType="Float" x="335" y="25" width="175" height="20" isRemoveLineWhenBlank="true" backcolor="#99ccff"/> <dataSourceExpression> new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource ($F{subReportBeanList}) </dataSourceExpression> <subreportExpression class="java.lang.String"> <![CDATA[$P{SUBREPORT_DIR} + "subReport.jasper"]]> </subreportExpression> </subreport> 

The same code works in the old version with a slight modification.

 <parameter name="subreportParameter" class="net.sf.jasperreports.engine.JasperReport"/> <subreport> <reportElement positionType="Float" x="1" y="2" width="532" height="15" isRemoveLineWhenBlank="true" backcolor="#99CCFF"/> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource ($F{subReportBeanList})]]></dataSourceExpression> <subreportExpression class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{subreportParameter}]]></subreportExpression> </subreport> 
+1
source

All Articles