java.lang.NoSuchMethodError:org.apache.poi.xwpf.usermodel.XWPFHyperlinkRun
我正在努力:java.lang.NoSuchMethodError:org.apache.poi.xwpf.usermodel.XWPFHyperlinkRun,java,amazon-ec2,ms-word,xwpf,xdocreport,Java,Amazon Ec2,Ms Word,Xwpf,Xdocreport,我正在努力: 使用带有“合并字段”的word文档填充数据 使用java将其转换为PDF文档 我以前做过这项工作,现在突然出现以下错误: java.lang.NoSuchMethodError: org.apache.poi.xwpf.usermodel.XWPFHyperlinkRun 当我将.war文件放在AmazonEC2服务器上时,就会发生这种情况。 (所有其他图书馆工作正常) 以下是我使用的库: fr.opensagres.xdocreport.converter.odt.odfdom(
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;
}
public byte[]wordToPdf(RequestHelper reqHelper,映射值,字符串docPath)引发IOException、XDocReportException、ServiceUnavailableException、E24Exception{
试一试{
ServletContext ctx=reqHelper.getRequest().getServletContext();
InputStream tpl=新的BufferedInputStream(ctx.getResourceAsStream(docPath));
IXDocReport report=XDocReportRegistry.getRegistry().loadReport(tpl,TemplateEngineKind.Velocity);
Options=Options.getTo(ConverterTypeTo.PDF).via(ConverterTypeVia.XWPF);
ByteArrayOutputStream pdfOut=新的ByteArrayOutputStream();
report.convert(report.createContext(值)、选项、pdfOut);
字节[]pdfImage=pdfOut.toByteArray();
返回pdfImage;
}
捕获(FileNotFoundException ex){
}
返回null;
}
好的,我终于找到了一个适合我的解决方案,因为这篇文章有很多观点,但没有答案,我会为那些需要帮助的人自己回答
我更改了所有与此相关的库的版本
“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)
/马库斯