Code:
- Code: Select all
try {
XmlSignaturePart sigPart = new XmlSignaturePart();
String sigXml = null;
File file = new File (fileName);
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(file);
Parts parts = wordMLPackage.getParts();
HashMap<PartName, Part> partsMap = parts.getParts();
for (PartName partName : partsMap.keySet()){
Part p = partsMap.get(partName);
if (p.getContentType().equals(ContentTypes.DIGITAL_SIGNATURE_XML_SIGNATURE_PART)){
sigPart = (XmlSignaturePart) p;
sigXml = sigPart.getXML();
}
}
} catch (Docx4JException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Error:
Exception in thread "main" java.lang.RuntimeException: javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "org.plutext.jaxb.xmldsig.SignatureType" as an element because it is missing an @XmlRootElement annotation]
at org.docx4j.XmlUtils.marshaltoString(XmlUtils.java:575)
at org.docx4j.openpackaging.parts.JaxbXmlPart.getXML(JaxbXmlPart.java:178)
at eci.edaexecute.signatureline.SignatureLineParse.main(SignatureLineParse.java:52)
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[com.sun.istack.internal.SAXException2: unable to marshal type "org.plutext.jaxb.xmldsig.SignatureType" as an element because it is missing an @XmlRootElement annotation]
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 org.docx4j.XmlUtils.marshaltoString(XmlUtils.java:563)
... 2 more
Caused by: com.sun.istack.internal.SAXException2: unable to marshal type "org.plutext.jaxb.xmldsig.SignatureType" as an element because it is missing an @XmlRootElement annotation
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.reportError(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)
... 6 more