报告()上的Jasperreports引擎JRRuntimeException.show [英] Jasperreports engine JRRuntimeException on report().show
问题描述
我正在使用DynamicReports和JasperReports创建一个Java应用程序.
I am creating a java application using DynamicReports and JasperReports.
尝试显示JasperReportBuilder时,出现此错误:
While trying to show the JasperReportBuilder, I get this error:
...
DEBUG DefaultExtensionsRegistry - Instantiating extensions registry for system.f
ont.families using factory class net.sf.dynamicreports.jasper.base.JasperSystemF
ontExtensionsRegistryFactory
Exception in thread "AWT-EventQueue-0" Exception in thread "AWT-EventQueue-0"
Exception: net.sf.jasperreports.engine.JRRuntimeException thrown from the UncaughtExceptionHandler in thread "AWT-EventQueue-0"
我的确在这里缺乏想法.我正在使用JDBC-ODBC桥来获取Access数据库(查询有效).我的代码(基本上是动态创建报告和列):
I am truly at a lack of ideas here. I am using JDBC-ODBC bridge to get an Access database (the query works). My piece of code (basically creating the report and the columns dynamically) :
JasperReportBuilder report = report();
try{
report.setTemplate(Templates.reportTemplate);
StyleBuilder titleStyle = stl.style(boldCenteredStyle)
.setVerticalAlignment(VerticalAlignment.MIDDLE)
.setFontSize(15);
report.title(cmp.horizontalList().add(cmp.image("resources/icon.jpg").setFixedDimension(80, 80)
, cmp.text("Gestion de rapports").setStyle(titleStyle)
, cmp.text(rapportSelect.getNomListe()).setStyle(titleStyle).setHorizontalAlignment(HorizontalAlignment.RIGHT))
.newRow().add(cmp.filler().setStyle(stl.style().setTopBorder(stl.pen2Point())).setFixedHeight(10)));
Iterator it = rapportSelect.getMappingColonnes().entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
report.columns(col.column((String)pair.getKey(), (String)pair.getValue(), type.stringType()));
}
report.pageFooter(Templates.footerComponent);
String sqlQuery = rapportSelect.getSqlQuery() + " ";
Statement stmt = GestionDbAdapter.getInstance().get().createStatement();
ResultSet rs = stmt.executeQuery(sqlQuery);
report.setDataSource(rs);
report.show(false);
整个应用程序非常大,所以我只放入了一段代码(我为堆栈溢出略做了清理).如果您需要更多代码,请告诉我.
The whole application is very big, so I only put a piece of my code (which I slightely cleaned for stackoverflow). Please advise me if you want more code.
推荐答案
我假设您像我一样遇到类似的问题.我有2种部署方式(没有网络方案):
I'm assuming that you've got a similiar problem just like me. I've got 2 kind of deployments (no web scenario):
- 所有独立JAR都放在单独文件中的应用程序部署
- 独立部署,将所有JAR打包到一个jar中(具有依赖关系的jar")
第二种情况无法正确执行,并且在与您所描述的位置相同的位置处以相同的错误中止.
The second scenario doesn't execute properly and aborts with the same error at the same location as you described.
原因是几个相关的JasperReport JAR在默认程序包级别的同一位置包含一个具有相同名称的属性文件:jasperreports_extension.properties
The reason was that several dependent JasperReport JARs contain a properties file with the same name at the same location on default package level: jasperreports_extension.properties
在独立的JAR方案中,它们彼此覆盖.最后,只有一个jasperreports_extension.properties
,因此对于有效的JasperReport,缺少一些键值对.
In the selfcontained JAR scenario they overwrite each other. Finally, there's only one jasperreports_extension.properties
and therefore some key-value pairs are missing for a working JasperReport.
解决方法:
收集所有jasperreports_extension.properties
文件并将其内容聚合到一个单独的jasperreports_extension.properties
中.确保您的部署获取此特殊文件,而不是原始文件.我在以下相关工件中发现重复的jasperreports_extension.properties
文件:
Collect all jasperreports_extension.properties
files and aggregate their contents into one single jasperreports_extension.properties
. Make sure that your deployment gets this special file instead of the original ones. I found duplicate jasperreports_extension.properties
files in following dependent artifacts:
- jasperreports-6.2.2.jar
- jasperreports-fonts-6.0.0.jar
- dynamicreports-core-4.1.1.jar
- dynamicreports-googlecharts-4.1.1.jar
这篇关于报告()上的Jasperreports引擎JRRuntimeException.show的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!