Page 1 of 1

OpenDoPEIntegrity NullPointerException

PostPosted: Sat Nov 01, 2014 3:11 am
by surfspider
I get a NullpointerException from the following code from your webapp example (https://github.com/plutext/OpenDoPE-WAR):

Code: Select all
OpenDoPEIntegrity odi = new OpenDoPEIntegrity();
odi.process(wordMLPackage);


The problem is that the xslt-Template is null in the method "process" of the OpenDoPEIntegrity class. So if the method "process" calls
Code: Select all
org.docx4j.XmlUtils.transform(doc, xslt, transformParameters, result);
it throws an NullPointerException. How can I solve this?

Re: OpenDoPEIntegrity NullPointerException

PostPosted: Sat Nov 01, 2014 7:43 am
by jason
I don't mean to teach you how to suck eggs, but of course you need to work out why that template is null.

I haven't had a problem with it, myself.

So verify it is being found; if it is, run in a debugger etc.

Sorry I can't help more based on present info.

Re: OpenDoPEIntegrity NullPointerException

PostPosted: Tue Nov 04, 2014 1:59 am
by surfspider
Thank you for your answer.

Now my word template with the content controls is filled:
I have included the xalan libaray in my deployment file even though the xalan libaray is a part of the application server Wildfly 8.1 which I am using. Because I included it in my deployment I exluded it in the jboss-deploxment-structure.xml configuration file.

But now I get a message that the generated document is corrupt.

I get following error in the log:

Code: Select all
2014-11-03 15:29:12,027 ERROR org.jboss.stdio.AbstractLoggingWriter.write(AbstractLoggingWriter.java:71) - Caused by: org.apache.xml.serializer.utils.WrappedRuntimeException: org.apache.xml.serializer.ToXMLSAXHandler cannot be cast to org.apache.xml.serializer.SerializationHandler

Re: OpenDoPEIntegrity NullPointerException

PostPosted: Wed Nov 05, 2014 4:11 pm
by jason
Add serializer-2.7.1 as well?

Re: OpenDoPEIntegrity NullPointerException

PostPosted: Wed Nov 12, 2014 8:23 pm
by surfspider
Yes I also included serializer-2.7.1.jar in my ear deployment file.

The bindings are applied and I can also open the generated word file, but MS Word displays a message that the word file is corrupt.

If I call applyBindings I still get the errors that org.apache.xml.serializer.ToXMLSAXHandler cannot be cast to org.apache.xml.serializer.SerializationHandler.

Does perhaps not exist a deployment instruction for the Wildfly 8.1 application server?

BindingHandler bh = new BindingHandler( wordMLPackage);
bh.applyBindings();


2014-11-12 10:07:57,088 INFO org.docx4j.model.datastorage.BindingTraverserXSLT.log(BindingTraverserXSLT.java:177) - [String] od:xpath=EKhTo
2014-11-12 10:07:57,133 DEBUG org.docx4j.wml.SdtPr.getTag(SdtPr.java:340) - found tag
2014-11-12 10:07:57,135 DEBUG org.docx4j.model.sdt.QueryString.parseQueryString(QueryString.java:119) - Query string: od:xpath=wmL8g
2014-11-12 10:07:57,136 DEBUG org.docx4j.model.datastorage.BindingTraverserXSLT.xpathGenerateRuns(BindingTraverserXSLT.java:750) - Looking for xpath with id: wmL8g referenced from part /word/document.xml at od:xpath=wmL8g
2014-11-12 10:07:57,147 DEBUG org.docx4j.openpackaging.parts.XmlPart.xpathGetString(XmlPart.java:139) - /vtbDataBO[1]/totalRS[1] ---> '999999.93'
2014-11-12 10:07:57,148 DEBUG org.docx4j.model.datastorage.BindingHandler.xpathGetString(BindingHandler.java:295) - /vtbDataBO[1]/totalRS[1] yielded result '999999.93'
2014-11-12 10:07:57,150 INFO org.docx4j.model.datastorage.BindingTraverserXSLT.xpathGenerateRuns(BindingTraverserXSLT.java:832) - /vtbDataBO[1]/totalRS[1] yielded result '999999.93'
2014-11-12 10:07:57,151 DEBUG org.docx4j.XmlUtils.unwrap(XmlUtils.java:322) - Unwrapped org.docx4j.wml.RPr
2014-11-12 10:07:57,153 DEBUG org.docx4j.XmlUtils.unwrap(XmlUtils.java:323) - name: {http://schemas.openxmlformats.org/wordprocessingml/2006/main}rPr
2014-11-12 10:07:57,156 DEBUG org.docx4j.model.datastorage.BindingHyperlinkResolver.getIndexOfURL(BindingHyperlinkResolver.java:65) - processing 999999.93
2014-11-12 10:07:57,160 DEBUG org.docx4j.jaxb.NamespacePrefixMapperUtils.setProperty(NamespacePrefixMapperUtils.java:164) - setProperty: com.sun.xml.bind.namespacePrefixMapper
2014-11-12 10:07:57,171 DEBUG org.docx4j.XmlUtils.treeCopy(XmlUtils.java:1228) - node type1
2014-11-12 10:07:57,173 DEBUG org.docx4j.XmlUtils.treeCopy(XmlUtils.java:1253) - copying: w:r
2014-11-12 10:07:57,174 DEBUG org.docx4j.XmlUtils.treeCopy(XmlUtils.java:1228) - node type1
2014-11-12 10:07:57,175 DEBUG org.docx4j.XmlUtils.treeCopy(XmlUtils.java:1253) - copying: w:rPr
2014-11-12 10:07:57,177 DEBUG org.docx4j.XmlUtils.treeCopy(XmlUtils.java:1228) - node type1
2014-11-12 10:07:57,178 DEBUG org.docx4j.XmlUtils.treeCopy(XmlUtils.java:1253) - copying: w:lang
2014-11-12 10:07:57,180 DEBUG org.docx4j.XmlUtils.treeCopy(XmlUtils.java:1228) - node type1
2014-11-12 10:07:57,181 DEBUG org.docx4j.XmlUtils.treeCopy(XmlUtils.java:1253) - copying: w:t
2014-11-12 10:07:57,182 DEBUG org.docx4j.XmlUtils.treeCopy(XmlUtils.java:1228) - node type3
2014-11-12 10:07:57,187 INFO org.docx4j.model.datastorage.BindingTraverserXSLT.log(BindingTraverserXSLT.java:177) - [String] od:xpath=wmL8g
2014-11-12 10:07:57,233 ERROR org.jboss.stdio.AbstractLoggingWriter.write(AbstractLoggingWriter.java:71) - org.apache.xml.serializer.utils.WrappedRuntimeException: org.apache.xml.serializer.ToXMLSAXHandler cannot be cast to org.apache.xml.serializer.SerializationHandler

2014-11-12 10:07:57,235 ERROR org.jboss.stdio.AbstractLoggingWriter.write(AbstractLoggingWriter.java:71) - at org.apache.xml.serializer.SerializerFactory.getSerializer(SerializerFactory.java:179)

2014-11-12 10:07:57,236 ERROR org.jboss.stdio.AbstractLoggingWriter.write(AbstractLoggingWriter.java:71) - at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:260)

2014-11-12 10:07:57,237 ERROR org.jboss.stdio.AbstractLoggingWriter.write(AbstractLoggingWriter.java:71) - at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:330)

2014-11-12 10:07:57,239 ERROR org.jboss.stdio.AbstractLoggingWriter.write(AbstractLoggingWriter.java:71) - at org.docx4j.XmlUtils.w3CDomNodeToString(XmlUtils.java:844)

Re: OpenDoPEIntegrity NullPointerException

PostPosted: Fri Nov 14, 2014 6:55 pm
by jason
Googling: org.apache.xml.serializer.ToXMLSAXHandler cannot be cast to org.apache.xml.serializer.SerializationHandler

Try the suggestions at http://stackoverflow.com/questions/4347 ... -xml-seria and https://issues.jboss.org/browse/JBEAP-19