Hello Jason thank you for your reply.
In the application I am using the starting point is a byteArrayInputAtream. what I then need to do is modify some fields and return a ByteArrayOutputStream to the applications. Everything works fine until I try to create the byte from the wordProcessingML.
The example I am using (based on yours is below:
- Code: Select all
private ByteArrayOutputStream convertToByteArray() throws Exception{
// FlatOpcXmlCreator worker = new FlatOpcXmlCreator(wordML);
OpcPackage pkg = wordML.getPackage();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SaveToZipFile saver = new SaveToZipFile(pkg);
saver.save(baos);
return baos;
}
The error that I am getting is basically a class loader issue when trying to load org/docx4j/jaxb/mc-preprocessor.xslt which I can see in the jar but because I am running this is a web container my class can't find the xslt in the class path and is not using the manifest.
Is there another way that I can convert to a byte array I can see that WordProcessingMLPackage has a helper method for loading a byteArray why can't it have another helper methord for returning a byteArray?.
Anyway the error I am getting below.
- Code: Select all
03.01.2014 10:20:33 *DEBUG* SaveToZipFile: For Relationship Id=rId1 Source is /word/header3.xml, Target is media/image1.png (SaveToZipFile.java, line 324)
03.01.2014 10:20:33 *DEBUG* SaveToZipFile: Getting part /word/media/image1.png (SaveToZipFile.java, line 365)
03.01.2014 10:20:33 *DEBUG* SaveToZipFile: org.docx4j.openpackaging.parts.WordprocessingML.ImagePngPart (SaveToZipFile.java, line 376)
03.01.2014 10:20:33 *DEBUG* SaveToZipFile: .. saving binary stuff (SaveToZipFile.java, line 415)
03.01.2014 10:20:33 *INFO * SaveToZipFile: success writing part: word/media/image1.png (SaveToZipFile.java, line 463)
03.01.2014 10:20:33 *DEBUG* SaveToZipFile: For Relationship Id=rId1 Source is /word/document.xml, Target is numbering.xml (SaveToZipFile.java, line 324)
03.01.2014 10:20:33 *DEBUG* SaveToZipFile: Getting part /word/numbering.xml (SaveToZipFile.java, line 365)
03.01.2014 10:20:33 *DEBUG* SaveToZipFile: org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart (SaveToZipFile.java, line 376)
03.01.2014 10:20:33 *DEBUG* SaveToZipFile: .. saving (SaveToZipFile.java, line 419)
03.01.2014 10:20:33 *INFO * JaxbXmlPart: marshalling org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart (JaxbXmlPart.java, line 323)
03.01.2014 10:20:33 *INFO * JaxbXmlPart: Lazily unmarshalling /word/numbering.xml (JaxbXmlPart.java, line 129)
03.01.2014 10:20:33 *INFO * JaxbXmlPartXPathAware: For org.docx4j.openpackaging.parts.WordprocessingML.NumberingDefinitionsPart, unmarshall via binder (JaxbXmlPartXPathAware.java, line 299)
03.01.2014 10:20:34 *WARN * JaxbValidationEventHandler: [ERROR] : unexpected element (uri:"http://schemas.microsoft.com/office/word/2010/wordml", local:"shadow"). Expected elements are < (JaxbValidationEventHandler.java, line 91)
03.01.2014 10:20:34 *INFO * JaxbValidationEventHandler: continuing (with possible element/attribute loss) (JaxbValidationEventHandler.java, line 107)
03.01.2014 10:20:34 *INFO * JaxbXmlPartXPathAware: encountered unexpected content; pre-processing (JaxbXmlPartXPathAware.java, line 324)
03.01.2014 10:20:34 *WARN * ResourceUtils: Couldn't get resource: org/docx4j/jaxb/mc-preprocessor.xslt (ResourceUtils.java, line 52)
03.01.2014 10:20:34 *ERROR* JaxbValidationEventHandler: Problem setting up mc-preprocessor.xslt (JaxbValidationEventHandler.java, line 61)
java.io.IOException: org/docx4j/jaxb/mc-preprocessor.xslt not found via classloader.
at org.docx4j.utils.ResourceUtils.getResource(ResourceUtils.java:54)
at org.docx4j.jaxb.JaxbValidationEventHandler.getMcPreprocessor(JaxbValidationEventHandler.java:56)
at org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware.unmarshal(JaxbXmlPartXPathAware.java:347)
at org.docx4j.openpackaging.parts.JaxbXmlPart.getJaxbElement(JaxbXmlPart.java:130)
at org.docx4j.openpackaging.parts.JaxbXmlPart.marshal(JaxbXmlPart.java:324)
at org.docx4j.openpackaging.parts.JaxbXmlPart.marshal(JaxbXmlPart.java:301)
at org.docx4j.openpackaging.io.SaveToZipFile.saveRawXmlPart(SaveToZipFile.java:247)
at org.docx4j.openpackaging.io.SaveToZipFile.saveRawXmlPart(SaveToZipFile.java:196)
at org.docx4j.openpackaging.io.SaveToZipFile.savePart(SaveToZipFile.java:420)
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:383)
at org.docx4j.openpackaging.io.SaveToZipFile.savePart(SaveToZipFile.java:438)
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:383)
at org.docx4j.openpackaging.io.SaveToZipFile.save(SaveToZipFile.java:166)
at eu.ema.dream.sbo.docxinjection.EMADocxInjection.convertToByteArray(EMADocxInjection.java:255)
at eu.ema.dream.sbo.docxinjection.EMADocxInjection.setDocxID(EMADocxInjection.java:305)
at eu.ema.dream.sbo.docxinjection.EMADocxInjection.setDocxID(EMADocxInjection.java:85)
at eu.ema.dream.bof.type.EMADocument.doSave(EMADocument.java:189)
at com.documentum.fc.client.DfPersistentObject.saveEx(DfPersistentObject.java:912)
at com.documentum.fc.client.DfPersistentObject.save(DfPersistentObject.java:907)
at eu.ema.dream.bof.type.EMADocument___PROXY.save(EMADocument___PROXY.java)
at com.documentum.operations.nodeactions.inbound.DfCheckinObject.checkin(DfCheckinObject.java:235)
at com.documentum.operations.nodeactions.inbound.DfCheckinObject.execute(DfCheckinObject.java:39)
at com.documentum.operations.steps.impl.OperationStep.executeStep(OperationStep.java:163)
at com.documentum.operations.steps.impl.OperationStep.execute(OperationStep.java:41)
at com.documentum.operations.impl.OperationExecutionEngine.execute(OperationExecutionEngine.java:51)
at com.documentum.operations.DfOperation.execute(DfOperation.java:401)
at com.documentum.operations.inbound.impl.InboundOperation.execute(InboundOperation.java:104)
at com.documentum.operations.inbound.DfImportOperation.execute(DfImportOperation.java:96)
at com.documentum.web.contentxfer.DFCOperationSupport.execute(DFCOperationSupport.java:61)
at com.documentum.web.contentxfer.ContentTransferService.execute(ContentTransferService.java:377)
at com.documentum.web.contentxfer.JobAdapter.execute(JobAdapter.java:108)
at com.documentum.job.async.AsyncJobManager$AsyncTimerJob.executeJob(AsyncJobManager.java:236)
at com.documentum.job.async.AsyncJobManager$AsyncTimerJob.run(AsyncJobManager.java:215)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
03.01.2014 10:20:34 *ERROR* JaxbXmlPart: No JAXBElement has been created for this part, yet! (JaxbXmlPart.java, line 326)
03.01.2014 10:20:34 *ERROR* JaxbXmlPart: No JAXBElement has been created for this part, yet! (JaxbXmlPart.java, line 334)
javax.xml.bind.JAXBException: No JAXBElement has been created for this part, yet!
at org.docx4j.openpackaging.parts.JaxbXmlPart.marshal(JaxbXmlPart.java:327)
at org.docx4j.openpackaging.parts.JaxbXmlPart.marshal(JaxbXmlPart.java:301)
at org.docx4j.openpackaging.io.SaveToZipFile.saveRawXmlPart(SaveToZipFile.java:247)
at org.docx4j.openpackaging.io.SaveToZipFile.saveRawXmlPart(SaveToZipFile.java:196)
at org.docx4j.openpackaging.io.SaveToZipFile.savePart(SaveToZipFile.java:420)
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:383)
at org.docx4j.openpackaging.io.SaveToZipFile.savePart(SaveToZipFile.java:438)
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:383)
at org.docx4j.openpackaging.io.SaveToZipFile.save(SaveToZipFile.java:166)
at eu.ema.dream.sbo.docxinjection.EMADocxInjection.convertToByteArray(EMADocxInjection.java:255)
at eu.ema.dream.sbo.docxinjection.EMADocxInjection.setDocxID(EMADocxInjection.java:305)
at eu.ema.dream.sbo.docxinjection.EMADocxInjection.setDocxID(EMADocxInjection.java:85)
at eu.ema.dream.bof.type.EMADocument.doSave(EMADocument.java:189)
at com.documentum.fc.client.DfPersistentObject.saveEx(DfPersistentObject.java:912)
at com.documentum.fc.client.DfPersistentObject.save(DfPersistentObject.java:907)
at eu.ema.dream.bof.type.EMADocument___PROXY.save(EMADocument___PROXY.java)
at com.documentum.operations.nodeactions.inbound.DfCheckinObject.checkin(DfCheckinObject.java:235)
at com.documentum.operations.nodeactions.inbound.DfCheckinObject.execute(DfCheckinObject.java:39)
at com.documentum.operations.steps.impl.OperationStep.executeStep(OperationStep.java:163)
at com.documentum.operations.steps.impl.OperationStep.execute(OperationStep.java:41)
at com.documentum.operations.impl.OperationExecutionEngine.execute(OperationExecutionEngine.java:51)
at com.documentum.operations.DfOperation.execute(DfOperation.java:401)
at com.documentum.operations.inbound.impl.InboundOperation.execute(InboundOperation.java:104)
at com.documentum.operations.inbound.DfImportOperation.execute(DfImportOperation.java:96)
at com.documentum.web.contentxfer.DFCOperationSupport.execute(DFCOperationSupport.java:61)
at com.documentum.web.contentxfer.ContentTransferService.execute(ContentTransferService.java:377)
at com.documentum.web.contentxfer.JobAdapter.execute(JobAdapter.java:108)
at com.documentum.job.async.AsyncJobManager$AsyncTimerJob.executeJob(AsyncJobManager.java:236)
at com.documentum.job.async.AsyncJobManager$AsyncTimerJob.run(AsyncJobManager.java:215)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
03.01.2014 10:20:34 *ERROR* SaveToZipFile: No JAXBElement has been created for this part, yet! (SaveToZipFile.java, line 304)
javax.xml.bind.JAXBException: No JAXBElement has been created for this part, yet!
at org.docx4j.openpackaging.parts.JaxbXmlPart.marshal(JaxbXmlPart.java:327)
at org.docx4j.openpackaging.parts.JaxbXmlPart.marshal(JaxbXmlPart.java:301)
at org.docx4j.openpackaging.io.SaveToZipFile.saveRawXmlPart(SaveToZipFile.java:247)
at org.docx4j.openpackaging.io.SaveToZipFile.saveRawXmlPart(SaveToZipFile.java:196)
at org.docx4j.openpackaging.io.SaveToZipFile.savePart(SaveToZipFile.java:420)
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:383)
at org.docx4j.openpackaging.io.SaveToZipFile.savePart(SaveToZipFile.java:438)
at org.docx4j.openpackaging.io.SaveToZipFile.addPartsFromRelationships(SaveToZipFile.java:383)
at org.docx4j.openpackaging.io.SaveToZipFile.save(SaveToZipFile.java:166)
at eu.ema.dream.sbo.docxinjection.EMADocxInjection.convertToByteArray(EMADocxInjection.java:255)
at eu.ema.dream.sbo.docxinjection.EMADocxInjection.setDocxID(EMADocxInjection.java:305)
at eu.ema.dream.sbo.docxinjection.EMADocxInjection.setDocxID(EMADocxInjection.java:85)
at eu.ema.dream.bof.type.EMADocument.doSave(EMADocument.java:189)
at com.documentum.fc.client.DfPersistentObject.saveEx(DfPersistentObject.java:912)
at com.documentum.fc.client.DfPersistentObject.save(DfPersistentObject.java:907)
at eu.ema.dream.bof.type.EMADocument___PROXY.save(EMADocument___PROXY.java)
at com.documentum.operations.nodeactions.inbound.DfCheckinObject.checkin(DfCheckinObject.java:235)
at com.documentum.operations.nodeactions.inbound.DfCheckinObject.execute(DfCheckinObject.java:39)
at com.documentum.operations.steps.impl.OperationStep.executeStep(OperationStep.java:163)
at com.documentum.operations.steps.impl.OperationStep.execute(OperationStep.java:41)
at com.documentum.operations.impl.OperationExecutionEngine.execute(OperationExecutionEngine.java:51)
at com.documentum.operations.DfOperation.execute(DfOperation.java:401)
at com.documentum.operations.inbound.impl.InboundOperation.execute(InboundOperation.java:104)
at com.documentum.operations.inbound.DfImportOperation.execute(DfImportOperation.java:96)
at com.documentum.web.contentxfer.DFCOperationSupport.execute(DFCOperationSupport.java:61)
at com.documentum.web.contentxfer.ContentTransferService.execute(ContentTransferService.java:377)
at com.documentum.web.contentxfer.JobAdapter.execute(JobAdapter.java:108)
at com.documentum.job.async.AsyncJobManager$AsyncTimerJob.executeJob(AsyncJobManager.java:236)
at com.documentum.job.async.AsyncJobManager$AsyncTimerJob.run(AsyncJobManager.java:215)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Any help would be much appreciated