爪哇岛的一个山洼。

2006-10-15

【技术心得】eclipse平台类加载器问题的解决

2006年7月30日晚上解决的问题,当时记录了,现在贴出来。原文如下:

今晚解决了一个问题,忍不住要记录一下,解决这个问题非常不容易,首先我要感谢Google,你是我最好的老师。

问题产生:我在eclipse的RCP程序中执行装载Jasper报表的程序。

// create JasperPrint using fillReport() method
JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, parameters, DBUtil.getConnection());

如果在eclipse平台外执行执行装载Jasper报表的程序正常,但在eclipse平台里执行就老是出这样的错误:

Unhandled event loop exceptionReason:net/sf/jasperreports/engine/fill/JRFillParameter

于是我开始在网上不断搜索,经过很久的搜寻,终于发现了类似问题的解决方法。
我在装载Jasper报表的程序前面加上这句话,就可以在eclipse RCP平台中运行了。

Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

1 条评论:

匿名 说...

顶一下!!!