NoSuchMethodException:org.apache.fop.apps.FopFactory.newInstance()

时间:2017-11-02 20:31:29

标签: java docx4j

此代码:

WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(is);
FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setWmlPackage(wordMLPackage);
Docx4J.toFO(foSettings, baos, Docx4J.FLAG_EXPORT_PREFER_XSL);
//Docx4J.toPDF(wordMLPackage, baos);

引发此错误:

  

java.lang.NoSuchMethodException:   org.apache.fop.apps.FopFactory.newInstance()at   java.lang.Class.getDeclaredMethod(Class.java:2130)at   org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.createFopFactory(FORendererApacheFOP.java:335)     在   org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.getFopFactory(FORendererApacheFOP.java:253)     在   org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:119)     在   org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:168)     在   org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:47)     在   org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:82)     在org.docx4j.Docx4J.toFO(Docx4J.java:575)

的Maven

<dependency>
    <groupId>org.docx4j</groupId>
    <artifactId>docx4j</artifactId>
    <version>3.3.6</version>
</dependency>
<dependency>
    <groupId>org.docx4j</groupId>
    <artifactId>docx4j-export-fo</artifactId>
    <version>3.3.6</version>
</dependency>

这里可能有什么问题?

1 个答案:

答案 0 :(得分:1)

乍一看,确认FOP 2.2在你的路上。

但是从堆栈跟踪来看,这看起来并不像export-fo v3.3.6,所以请检查您的类路径以确保您没有早期的导出。