首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

Ireport 空指针错误

2012-03-23 
Ireport 空指针异常这是我的测试public static void main(String[] args) {MapString,String paramsnew

Ireport 空指针异常
这是我的测试
public static void main(String[] args) {

Map<String,String> params=new HashMap<String,String>();
params.put("spring", "spring");
try {
InputStream is = new FileInputStream("C:/Users/lenovo/Desktop/report/report2.jasper");
System.out.println(is);
JasperReport jasperReport =(JasperReport) JRLoader.loadObject(is);
JasperPrint jasperPrint=JasperFillManager.fillReport(jasperReport, params);
JasperViewer.viewReport(jasperPrint,false);

} catch (Exception e) {
e.printStackTrace();
}
}
异常
java.lang.NullPointerException
at net.sf.jasperreports.engine.JRPropertiesMap.readObject(JRPropertiesMap.java:185)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readArray(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:88)
at net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:64)
at report.ReportTest.main(ReportTest.java:25)
那个is的值是有的。

[解决办法]
JRPropertiesMap.java:185 debug看看那个变量值是null

热点排行