Applet加载错误 - Jasper报告

时间:2012-12-05 17:01:18

标签: java applet jasper-reports

我的applet遇到了一个错误,我无法找到解决方案。我正在加载我的java applet,其中包含一个简单的jasper查看器。加载applet时会抛出以下异常:

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)

下面是我的applet配置,我正在使用标准的java部署工具包加载applet。

<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>

applet中我需要的所有jar都存在于我的webroot的资源文件夹中,

  • appletviewer.jar
  • 公地BeanUtils的-1.8.0.jar
  • commons-collections-3.2.1.jar
  • 公地消化器-1.7.jar
  • commons-javaflow-20060411.jar
  • 共享记录-1.0.4.jar
  • jasperreports-4.0.0.jar
  • JasperReports的小程序-4.0.0.jar
  • ORG-netbeans的-core.jar添加

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

The java console from control panel

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

1 个答案:

答案 0 :(得分:0)

错误来自服务器端我在跟踪控制台日志之后就知道了,在我的服务器类路径中,comons-collections丢失了,我添加了它并且工作正常。