Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.NoSuchMethodError:org.apache.poi.xwpf.usermodel.XWPFHyperlinkRun_Java_Amazon Ec2_Ms Word_Xwpf_Xdocreport - Fatal编程技术网

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(

我正在努力:

  • 使用带有“合并字段”的word文档填充数据
  • 使用java将其转换为PDF文档
  • 我以前做过这项工作,现在突然出现以下错误:

    java.lang.NoSuchMethodError: org.apache.poi.xwpf.usermodel.XWPFHyperlinkRun

    当我将.war文件放在AmazonEC2服务器上时,就会发生这种情况。 (所有其他图书馆工作正常)

    以下是我使用的库:

    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;
        }
    
    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)

    /马库斯