Jump to content
JasperReports Library 7.0 is now available ×

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

Go to solution Solved by tthornburg,

Recommended Posts

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:

      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();
        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);

        JasperExportManager.exportReportToPdfStream(jasperPrint, out);

        // Go ahead and close the output stream (we're done)

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.

Link to comment
Share on other sites

  • 3 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...