Page 1 of 1

*ERROR* XmlUtils: java.lang.NoSuchMethodException:

PostPosted: Tue Oct 25, 2011 9:41 am
by frankf
*ERROR* XmlUtils: java.lang.NoSuchMethodException: For extension function, could not find method static org.docx4j.model.datastorage.BindingHandler.xpathGenerateRuns([ExpressionContext,] #UNKNOWN (org.docx4j.openpackaging.packages.WordprocessingMLPackage), #UNKNOWN (java.util.HashMap), #STRING, #STRING, #STRING, #NODESET, #BOOLEAN). (XmlUtils.java, line 940)
; Line#: 69; Column#: 29

Using docx4j 2.7.1, October 14, 2011, downloaded jar file.

Test file with a table with a repeating row that contains two control fields (attached).

applyBinding works both with build 1620 and the above jar file, properly populating the target file, Word opens it fine, all looks good.

However, the above exception appears multiple times in the eclipse log file as a result of the call to applyBinding when using the above jar file.

Checked the source for build 1698, and the argument pattern in the exception, as noted, does not appear in BindingHandler.xpathGenerateRuns.

Test file attached. Passed this string as the new XML:

Code: Select all
<yourxml><row><fielda>fieldx</fielda><fieldb>fieldy</fieldb></row><row><fielda>fieldr</fielda><fieldb>fields</fieldb></row></yourxml>


Code (error handling omitted):
Code: Select all
OpenDoPEHandler odh = new OpenDoPEHandler(wordMLPackage);
odh.preprocess();

OpenDoPEIntegrity odi = new OpenDoPEIntegrity();
odi.process(wordMLPackage);

BindingHandler.applyBindings(wordMLPackage);

wordMLPackage.save(new File(sTemplatePath));


Suggestions? Full exception message below:

javax.xml.transform.TransformerException: java.lang.NoSuchMethodException: For extension function, could not find method static org.docx4j.model.datastorage.BindingHandler.xpathGenerateRuns([ExpressionContext,] #UNKNOWN (org.docx4j.openpackaging.packages.WordprocessingMLPackage), #UNKNOWN (java.util.HashMap), #STRING, #STRING, #STRING, #NODESET, #BOOLEAN).
at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:422)
at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:440)
at org.apache.xalan.extensions.ExtensionsTable.extFunction(ExtensionsTable.java:222)
at org.apache.xalan.transformer.TransformerImpl.extFunction(TransformerImpl.java:473)
at org.apache.xpath.functions.FuncExtFunction.execute(FuncExtFunction.java:208)
at org.apache.xpath.XPath.execute(XPath.java:337)
at org.apache.xalan.templates.ElemCopyOf.execute(ElemCopyOf.java:134)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:141)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1376)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
at org.apache.xalan.templates.ElemCopy.execute(ElemCopy.java:116)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
at org.apache.xalan.templates.ElemChoose.execute(ElemChoose.java:128)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
at org.apache.xalan.templates.ElemCopy.execute(ElemCopy.java:116)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
at org.apache.xalan.templates.ElemCopy.execute(ElemCopy.java:116)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
at org.apache.xalan.templates.ElemCopy.execute(ElemCopy.java:116)
at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395)
at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:178)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
at org.apache.xalan.templates.ElemCopy.execute(ElemCopy.java:132)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2400)
at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2270)
at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1356)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:709)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1273)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1251)
at org.docx4j.XmlUtils.transform(XmlUtils.java:830)
at org.docx4j.XmlUtils.transform(XmlUtils.java:723)
at org.docx4j.model.datastorage.BindingHandler.applyBindings(BindingHandler.java:176)
at org.docx4j.model.datastorage.BindingHandler.applyBindings(BindingHandler.java:125)

Re: *ERROR* XmlUtils: java.lang.NoSuchMethodException:

PostPosted: Tue Oct 25, 2011 10:57 pm
by jason
Hi Frank

I've tried to reproduce this, but can't. First I used docx4j 2.7.1 from Maven Central, then I tried using http://www.docx4java.org/docx4j/docx4j-2.7.1.tar.gz

Both times, I used a new Eclipse project, and things worked fine.

So I suspect you've got an old docx4j jar or class files on your path.

cheers .. Jason

Re: *ERROR* XmlUtils: java.lang.NoSuchMethodException:

PostPosted: Wed Oct 26, 2011 3:33 am
by frankf
Jason,

You are right. It's the only thing that makes sense. And the older pattern it couldn't find was in the 1620 code, so it had to be finding that older docx4j.jar file somehow. It took a while. I didn't have the old jar file anywhere as docx4j.jar file, but I did have some older versions named similar to docx4j-2.7.0.jar in the same directory as the 2.7.1 docx4j.jar file. Didn't think it would use the mis-named jar files, but once I removed the older files, all is well. Thanks!