无法编译 JasperReports 的 webapp 示例

发布于 2024-12-12 02:17:38 字数 3945 浏览 0 评论 0原文

这是我第一次在官方发行版中运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

临走之时 2024-12-19 02:17:38

这是由于一个 bug(在我们的 JasperServer 中),JDT 编译器编译从缓存加载的报告缺少类路径上的 scriptlet。最初运行报告时不会发生这种情况,因为在这种情况下,JDT 求值器(而不是编译器)与类路径上的 scriptlet 一起使用。换句话说:

  1. 使用 JDT 评估器运行报表,将 scriptlet 添加到类路径
  2. 报表从缓存加载并使用 JDT 编译器进行编译,类路径上没有 scriptlet(因为 JDT 编译器与包含的应用程序共享其类路径,相反到有自己的类路径的评估器)。

快速解决方法是将 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:

  1. Report is run using the JDT evaluator, scriptlet is added to the classpath
  2. Report is loaded from cache and compiled using JDT compiler, without the scriptlet on the classpath (because the JDT compiler shares its classpath with the containing application, in contrary to the evaluator which has its own classpath).

The quick fix is to add the scriptlet to your containing application's classpath.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文