Can't export to PDF Stream...NoSuchFieldError: APPDEFAULT What is missing???

0

I've seen other's postings on this issue and believe that my code is in compliance with the suggested solutions but still receive this error when attempting to export to PDF output stream:

StandardWrapperValve[Dispatcher]: PWC1406: Servlet.service() for servlet Dispatcher threw exception
java.lang.NoSuchFieldError: APPDEFAULT
        at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:532)
        at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:396)
        at net.sf.jasperreports.engine.JasperExportManager.exportToPdfStream(JasperExportManager.java:191)
        at net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfStream(JasperExportManager.java:527)
        at com.aphoristics.stache.servlet.report.SqlJasperReport.buildJasperReport(SqlJasperReport.java:341)
        at com.aphoristics.stache.servlet.report.SqlJasperReport.run(SqlJasperReport.java:259)
        at com.aphoristics.stache.servlet.report.Dispatcher.processRequest(Dispatcher.java:193)
        at com.aphoristics.stache.servlet.report.Dispatcher.doGet(Dispatcher.java:234)

jasperreports-4.7.1 jar; iText-2.1.7 jar; java 1.6.0_32; appserver is Sun Glassfish Enterprise Server 2.1.1; Client is running windows 7 64-bit.

I have the iText-2.1.7.jar in the classpath as was specified in one response on a similar error.

This servlet handles a variety of outputs and was written against the 1.3.4 version of the jasperreports library so am attempting to bring the code up to date with the latest version of the api. 

Here are snippets of the code:

      m_masterReport.execute();
      JasperPrint jasperPrint = JasperFillManager.fillReport(m_masterReport.report, masterParams, m_masterReport.getDataSource());

      // check for no data
      if (jasperPrint.getPages().isEmpty())
      {
        RequestDispatcher dispatcher = ((Dispatcher)hreq.getAttribute("Dispatcher")).getServletContext().getRequestDispatcher("/reports/jsp/NoData.jsp");
        dispatcher.forward(hreq, response);
      }
     else if (m_type.equalsIgnoreCase("PDF"))
      {
        ServletOutputStream out = response.getOutputStream();
        response.setContentType("application/PDF");
/*
        JRPdfExporter PDFExport = new JRPdfExporter();
        PDFExport.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
        PDFExport.setParameter(JRPdfExporterParameter.PDF_VERSION, JRPdfExporterParameter.PDF_VERSION_1_6);
        PDFExport.setParameter((JRExporterParameter.JASPER_PRINT), jasperPrint);
        PDFExport.exportReport();
 */

        JasperExportManager.exportReportToPdfStream(jasperPrint, out);

        // Go ahead and close the output stream (we're done)
        out.close();
      }

As you can see the original code used the JRPdfExporter class but has been replaced as was also advised in the other posting on this issue with the facade class JasperExportManager method call to export to a pdf stream.  Please advise if there are other known issues or other dependencies of which I may not be aware.

tthornburg's picture
Joined: Oct 16 2012 - 9:23am
Last seen: 6 years 9 months ago

1 Answer:

0

In the end, the issue did boil down to old copies of the itext.jar in the path.

tthornburg's picture
Joined: Oct 16 2012 - 9:23am
Last seen: 6 years 9 months ago
Feedback