我试图:
我以前做过这样的工作,现在突然间我得到了以下错误:
org.apache.poi.xwpf.usermodel.XWPFHyperlinkRun.:java.lang.NoSuchMethodError
当我将.war文件放在Amazon服务器上时,就会发生这种情况。(所有其他图书馆运作良好)
下面是我使用的库:
fr.opensagres.xdocreport.converter.odt.odfdom (v1.0.4) fr.opensagres.xdocreport.template.freemarker (v1.0.4) org.apache.poi.xwpf.converter.core (1.0.5) org.apache.poi.xwpf.converter.pdf (1.0.5) org.apache.poi.xwpf.converter.xhtml (1.0.5) org.apache.poi (3.11)
我的图书馆有什么问题吗?或者这仅仅是一个服务器部署问题?
非常感谢你的帮助。
下面是我的代码:
public byte[] wordToPdf(RequestHelper reqHelper, Map<String, Object> values, String docPath) throws IOException, XDocReportException, ServiceUnavailableException, E24Exception {
try {
ServletContext ctx = reqHelper.getRequest().getServletContext();
InputStream tpl = new BufferedInputStream(ctx.getResourceAsStream(docPath));
IXDocReport report = XDocReportRegistry.getRegistry().loadReport(tpl, TemplateEngineKind.Velocity);
Options options = Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.XWPF);
ByteArrayOutputStream pdfOut = new ByteArrayOutputStream();
report.convert(report.createContext(values), options, pdfOut);
byte[] pdfImage = pdfOut.toByteArray();
return pdfImage;
}
catch (FileNotFoundException ex) {
}
return null;
}发布于 2017-02-23 09:20:04
好的,我终于找到了一个对我有用的解决方案,因为这篇文章有很多观点而没有答案,我会亲自回答那些需要帮助的人!
我将与"apache.poi“相关的所有库的版本更改为1.0.4
之后,我使用了org.apache.poi版本3.9,而不是3.11
所以最后,结束它..。这是我最后用过的
org.apache.poi.xwpf.converter.core (1.0.4) org.apache.poi.xwpf.converter.pdf (1.0.4) org.apache.poi.xwpf.converter.xhtml (1.0.4) org.apache.poi (3.9)
/Marcus
https://stackoverflow.com/questions/42206898
复制相似问题