0

我的小程序遇到了一个错误,我无法找出解决方案。我正在加载我的 java 小程序,其中包含一个简单的碧玉查看器。加载小程序时,它会引发以下异常:

SEVERE: Servlet.service() for servlet JasperReportServlet threw exception
java.lang.ClassNotFoundException: org.apache.commons.collections.ReferenceMap
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.<init>(DefaultExtensionsRegistry.java:96)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at net.sf.jasperreports.engine.util.ClassUtils.instantiateClass(ClassUtils.java:59)
    at net.sf.jasperreports.extensions.ExtensionsEnvironment.createDefaultRegistry(ExtensionsEnvironment.java:80)
    at net.sf.jasperreports.extensions.ExtensionsEnvironment.<clinit>(ExtensionsEnvironment.java:68)
    at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:76)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:182)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:77)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:87)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)
    at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:142)
    at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:78)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
    at com.dbhl.app.report.generator.JobUpdateGenerator.getJasperPrintObject(JobUpdateGenerator.java:279)
    at com.dbhl.app.report.JasperReportServlet.processJobUpdate(JasperReportServlet.java:153)
    at com.dbhl.app.report.JasperReportServlet.getJasperPrintObjectByLedgerType(JasperReportServlet.java:79)
    at com.dbhl.app.report.JasperReportServlet.service(JasperReportServlet.java:50)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    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:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    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:263)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)

下面是我的小程序配置,我正在使用标准 Java 部署工具包加载小程序。

<script type="text/javascript" src="<%=basePath%>js/deployJava.js">
</script>

<script>
  var user = '<%=request.getParameter("user")%>';

  var attributes = {
    code : 'applet.EmbeddedViewerApplet.class',
    archive : '<%=basePath%>resources/appletviewer.jar,<%=basePath%>resources/jasperreports-applet-4.0.0.jar,<%=basePath%>resources/jasperreports-4.0.0.jar,<%=basePath%>resources/commons-collections-3.2.1.jar,<%=basePath%>resources/commons-logging-1.0.4.jar,<%=basePath%>resources/commons-beanutils-1.8.0.jar,<%=basePath%>resources/commons-digester-1.7.jar,<%=basePath%>resources/commons-javaflow-20060411.jar,<%=basePath%>resources/org-netbeans-core.jar',
    width : "100%",
    height : 600
  };

  var parameters = {
    fontSize : 16,
    REPORT_URL : '<%=basePath%>servlet/JasperReportServlet?startDate=<%=request.getParameter("startDate")%>&endDate=<%=request.getParameter("endDate")%>&user=' + user + '&reportType=<%=request.getParameter("reportType")%>'
  };

  var version = '1.4';
  deployJava.runApplet(attributes, parameters, version);
</script>

我在小程序中需要的所有 jar 都存在于我的 webroot 的资源文件夹中,它们是

  • 小程序查看器.jar
  • commons-beanutils-1.8.0.jar
  • commons-collections-3.2.1.jar
  • commons-digester-1.7.jar
  • commons-javaflow-20060411.jar
  • commons-logging-1.0.4.jar
  • jasperreports-4.0.0.jar
  • jasperreports-applet-4.0.0.jar
  • org-netbeans-core.jar

所有的罐子都是今天签名的,所以没有过期。我已经仔细检查了所有内容,但它总是显示上述错误。在 iReport 中,我可以查看报告,它被编译为 jasper 对象,没有错误。

控制面板中的 java 控制台

我在临时缓存中检查了集合文件已成功下载,并且在上面的控制台日志中显示 jar 已成功下载到主机。 为什么会这样ClassNotFoundException

4

1 回答 1

0

错误来自服务器端,我在跟踪控制台日志后才知道,在我的服务器类路径中缺少 comons-collections,我添加了它并且一切正常。

于 2012-12-06T10:28:06.393 回答