无法编译 JasperReports 的 webapp 示例
这是我第一次在官方发行版中运行 JasperReports 的 webapp 示例。 我将 \dist 和 \lib 中的 jar 放入 webapp 示例中,并将 webapp-sample 的整个目录部署到 tomcat 中。 但是当我尝试使用默认页面编译 WebappReport.jrxml 时,我看到一个 error.jsp,它显示以下提示:
JasperReports 遇到此错误:
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
2. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
3. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
4. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
5. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
6. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
6 errors
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:191)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:212)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:128)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:87)
at org.apache.jsp.jsp.compile_jsp._jspService(compile_jsp.java:61)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
at java.lang.Thread.run(Thread.java:619)
It's my first time to run the the webapp sample of the JasperReports in the offical distribution.
I put the jar in the \dist and \lib into the webapp sample and deployed the whole dir of the webapp-sample into tomcat.
But when I try to use the default page to compile the WebappReport.jrxml, I see an error.jsp, and it shows me the following prompt:
JasperReports encountered this error :
net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
2. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
3. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
4. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
5. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
6. scriptlets.WebappScriptlet cannot be resolved to a type
value = ((scriptlets.WebappScriptlet)((scriptlets.WebappScriptlet)parameter_REPORT_SCRIPTLET.getValue())).hello(); //$JR_EXPR_ID=23$
<------------------------>
6 errors
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:191)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:212)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:128)
at net.sf.jasperreports.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:87)
at org.apache.jsp.jsp.compile_jsp._jspService(compile_jsp.java:61)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
at java.lang.Thread.run(Thread.java:619)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是由于一个 bug(在我们的 JasperServer 中),JDT 编译器编译从缓存加载的报告缺少类路径上的 scriptlet。最初运行报告时不会发生这种情况,因为在这种情况下,JDT 求值器(而不是编译器)与类路径上的 scriptlet 一起使用。换句话说:
快速解决方法是将 scriptlet 添加到包含应用程序的类路径中。
This is due to a bug (in our case in JasperServer) where a report loaded from cache is being compiled by the JDT compiler is missing the scriptlet on the classpath. This does not happen when the report is run initially because in that case the JDT evaluator (instead of the compiler) is used with the scriptlet on the classpath. In other words:
The quick fix is to add the scriptlet to your containing application's classpath.