我正在尝试为 Eclipse BIRT 报告编写扩展(插件)。它涉及根据数据库条目从文件中提取图像并显示它们。
我正在使用 Sun 的 JAI-ImageIO 访问 TIFF 文件数据并转换为 PNG 以在报告中显示。我的代码符合要求,但会引发 NoClassDefFound 运行时异常:
SEVERE: Error happened while running the report.
java.lang.NoClassDefFoundError: javax/media/jai/PlanarImage
at org.eclipse.birt.sample.reportitem.rotatedlabel.util.GraphicsUtil.createDocImage
(GraphicsUtil.java:66)
at org.eclipse.birt.sample.reportitem.rotatedlabel.RotatedLabelPresentationImpl.onRowSets
(RotatedLabelPresentationImpl.java:136)
at org.eclipse.birt.report.engine.extension.ReportItemPresentationBase.onRowSets
(ReportItemPresentationBase.java:218)
at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.
processExtendedContent(LocalizedContentVisitor.java:966)
...
我正在使用 PlanarImage.getAsBufferedImage() 方法,因此它应该转换为更标准的图像对象。我已将 JAI jar 文件放在我的 JRE 中,并在 Eclipse 插件环境之外测试了相同的基本代码——效果很好。这似乎是一个 CLASSPATH 问题,但我已经验证了我系统上的所有 JRE 在适当的位置都包含必要的 jar 和 DLL 文件。
对于新的 JDBC 驱动程序,您必须将 jar(s) 放在插件的一个特殊子目录中——是否有一个特殊的位置可以放置其他第三方 jar 以便 BIRT 可以使用它们?