Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
201 views
in Technique[技术] by (71.8m points)

javascript - Cannot compile webapp sample of JasperReports

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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...