Question

i am using the code at for creating pdf using Apache FOP

but i am getting these exceptions when i run the code

Hi Testing
javax.xml.bind.MarshalException
 - with linked exception:
 [com.sun.istack.internal.SAXException2: class com.testFOP.Employee nor any of its         super class is known to this context.


  javax.xml.bind.JAXBException: class com.testFOP.Employee nor any of its super class     is known to this context.]
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown Source)
    at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(Unknown Source)
    at com.testFOP.PDFHandler.getXMLSource(PDFHandler.java:97)
    at com.testFOP.TestPDF.main(TestPDF.java:37)
     Caused by: com.sun.istack.internal.SAXException2: class com.testFOP.Employee nor any     of its super class is known to this context.
     javax.xml.bind.JAXBException: class com.testFOP.Employee nor any of its super class      is known to this context.
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown      Source)
    at      com.sun.xml.internal.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(Unknow     n Source)
    at com.sun.xml.internal.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.property.ArrayERProperty.serializeBody(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsSoleContent(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(Unknown Source)
    at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(Unknown Source)
    ... 5 more
     Caused by: javax.xml.bind.JAXBException: class com.testFOP.Employee nor any of its      super class is known to this context.
    at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getBeanInfo(Unknown Source)
    ... 13 more
     Error on line 1 column 1 
       SXXP0003: Error reported by XML parser: Premature end of file.
     net.sf.saxon.trans.XPathException: org.xml.sax.SAXParseException; lineNumber: 1;           columnNumber: 1; Premature end of file.
    at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:420)
    at net.sf.saxon.event.Sender.send(Sender.java:169)
    at net.sf.saxon.Controller.transform(Controller.java:1890)
    at com.testFOP.PDFHandler.createPDFFile(PDFHandler.java:64)
    at com.testFOP.TestPDF.main(TestPDF.java:39)
     Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature      end of file.
    at                com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown      Source)
    at                                                                                      com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown      Source)
    at      com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown      Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown      Source)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown      Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown      Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown      Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown      Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown      Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown      Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown      Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown           Source)
    at      com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:396)
    ... 4 more
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:396)
    at net.sf.saxon.event.Sender.send(Sender.java:169)
    at net.sf.saxon.Controller.transform(Controller.java:1890)
    at com.testFOP.PDFHandler.createPDFFile(PDFHandler.java:64)
    at com.testFOP.TestPDF.main(TestPDF.java:39)

can any one help me to solve these issues. thanks in advance

Était-ce utile?

La solution

The problem can be sloved .. Please make following changes to "PDFHandler.java"..

    try {
        context = JAXBContext.newInstance(EmployeeData.class,Employee.class);
        Marshaller m = context.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        m.marshal(data, outStream);
    } catch (JAXBException e) {

        e.printStackTrace();
    }

And generated pdf will be placed in this location (in windows 7 os ) "C:\Users\narendar.g\AppData\Local\Temp" like 13891730308241855417914089056114.pdf

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top