我尝试在JasperServer上使用报告,这是我在iReport的帮助下创建的。在iReport中,我的报告工作正常,没有错误。但是,当我尝试部署报告时,它简单地给出了以下错误:
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date
和完整的错误:
The server has encountered an error. Please excuse the inconvenience.
Error Message
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date
Error Trace
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.setDate(JRJdbcQueryExecuter.java:649)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.setStatementParameter(JRJdbcQueryExecuter.java:577)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.setStatementParameter(JRJdbcQueryExecuter.java:399)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter$1.visit(JRJdbcQueryExecuter.java:332)
at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter$QueryParameter.accept(JRAbstractQueryExecuter.java:157)
at net.sf.jasperreports.engine.query.JRAbstractQueryExecuter.visitQueryParameters(JRAbstractQueryExecuter.java:646)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createStatement(JRJdbcQueryExecuter.java:317)
at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:196)
at com.jaspersoft.jasperserver.api.engine.jasperreports.util.JRTimezoneJdbcQueryExecuter.createDatasource(JRTimezoneJdbcQueryExecuter.java:168)
at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1087)
at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:668)
at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1258)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:877)
at net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFiller.run(BaseFillHandle.java:120)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$SynchronousExecutor.execute(EngineServiceImpl.java:875)
at net.sf.jasperreports.engine.fill.BaseFillHandle.startFill(BaseFillHandle.java:165)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$AsynchronousReportFiller.fillReport(EngineServiceImpl.java:831)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.fillReport(EngineServiceImpl.java:1658)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportFill.runReport(EngineServiceImpl.java:1022)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportRunnable.run(EngineServiceImpl.java:897)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
我上传了报告,获得了正确的数据源(我已经用另一份报告对其进行了测试)并导入了我的资源(子报告)和输入控件。我不知道我是否错过了一步,但我很确定我做了所需的一切。导入每个子报表,设置输入控件会声明正确的路径repo:mySubreports.jrxml
。如果您需要更多信息,请告诉我!我想我添加了所有必需的信息,而且我不想用无用的信息来垃圾邮件,因为我现在也不知道哪些信息有用:)
答案 0 :(得分:1)
我认为这与报告中的日期参数/变量有关。
请确保您对Jasperserver中日期参数的输入控制是java.util.date
我看到自己重复的一个常见错误就是将一个默认值表达式(如空""
)用于声明它们的日期参数/变量。在这种情况下,我看到了报告在ireport中工作也会在服务器中上传而不会出现任何错误,但它会抛出
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Date Error Trace
请使用报告的所有日期参数检查上述两点,如果可行,请在此处更新
由于
钱德拉