Vijay
Vijay

Reputation: 8451

JasperReports: filling a report throws an exception “TargetInvocationException”

Exception:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.lang.reflect.InvocationTargetException
    org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
    org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
    org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
    com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
    org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
    org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)

Code:

 PreparedStatement ps = conn.prepareCall("{ call StoreProcedureDemo(?) }");
                ps.setString(1,condition);

            ResultSet rs = ps.executeQuery();

            //  System.out.println("Inside ordersheetReport");
               HashMap jasperParameter = new HashMap();
               JasperReport jasperReport;
               JasperPrint jasperPrint = null;

               try
               {
                   File file = new File(Paths.FTPPath+"PDF/"+name+".pdf");
                   file.delete();

               }catch (Exception e) {
                // TODO: handle exception
            }
               System.out.println("1");
            JRResultSetDataSource rsss = new JRResultSetDataSource(rs);
            System.out.println("2");
            jasperReport = JasperCompileManager.compileReport(Paths.FTPPath+"JRXML/OrderSheet.jrxml");
            System.out.println(" jasperReport "+Paths.FTPPath+"JRXML/OrderSheet.jrxml");
            //JasperFillManager.fillReportToFile("D:/reports/test.jasper", jasperParameter, rsss);
            try{
                System.out.println("try 3.1.");
                jasperPrint = JasperFillManager.fillReport(jasperReport,jasperParameter, rsss);
                System.out.println("try 3.2.");
            }catch (JRException e) {
                System.out.println("catch 3..");
                e.printStackTrace();
            }
            catch (Exception e) {
                e.printStackTrace();
            }
            //JasperPrintManager.printReport(jasperPrint,true);

            JasperExportManager.exportReportToPdfFile(jasperPrint, Paths.FTPPath+"PDF/"+name+".pdf");

        }catch(JRException e)
        {
            //  System.out.println("precriptionReport :  "+e);
            e.printStackTrace();
        }

I am able to get log till System.out.println("try 3.1.");.

Upvotes: 1

Views: 1117

Answers (2)

Vijay
Vijay

Reputation: 8451

here problem with tomcat jar and application jar.(might be conflict with jar file).. I have changed my tomcat server form 6 to 8 version and that works fine for me..

thanks to all your their time..

Upvotes: 2

Endrik
Endrik

Reputation: 2258

InovcationTargetException means that the method that you invoked threw an exception. To figure out what the problem is with your method itself, you can try using a getCause() on a cought Throwable. Instead of directly compiling the jrxml file .compileReport(Paths.FTPPath+"JRXML/OrderSheet.jrxml")

try first using jasper loader :

JasperDesign design = JRXmlLoader.load(Paths.FTPPath+"JRXML/OrderSheet.jrxml");
JasperReport report = JasperCompileManager.compileReport(design);

Otherwise, the problem could derive from the connection, (i can see the prepared statement from your code, but not the connection details).

Upvotes: 2

Related Questions