我正在使用 apache poi 从 doc , docx 等各种文档文件中提取文本。我的代码在 Windows 中运行良好,但在部署到测试服务器之后它无法运行。
服务器操作系统:Amazon Linux 环境:AWS
这是我的代码段:
if(extension.equals("docx")){
XWPFDocument document = new XWPFDocument(new FileInputStream(resume));
XWPFWordExtractor we = new XWPFWordExtractor(document);
resumeAsText = we.getText();
} else if(extension.equals("doc")){
Word6Extractor extractor = new Word6Extractor(new FileInputStream(resume));
resumeAsText = extractor.getText();
} else if(extension.equals("pdf")){
PDFParser parser = new PDFParser(new FileInputStream(resume));
parser.parse();
COSDocument cosDoc = parser.getDocument();
PDFTextStripper pdfStripper = new PDFTextStripper();
PDDocument pdDoc = new PDDocument(cosDoc);
resumeAsText = pdfStripper.getText(pdDoc);
cosDoc.close();
pdDoc.close();
} else if(extension.equals("rtf")){
RTFEditorKit rtfParser = new RTFEditorKit();
Document document = rtfParser.createDefaultDocument();
rtfParser.read(new FileInputStream(resume), document, 0);
resumeAsText = document.getText(0, document.getLength());
}
我收到此错误:
org.apache.catalina.core.ApplicationFilterChain.doFilter(Appli
11:18:34,337 ERROR [http-bio-8080-exec-85][PortletServlet:116] javax.portlet.PortletException: java.lang.NoSuchMethodError: org.apache.poi.util.IOUtils.toByteArray(Ljava/io/InputStream;)[B
javax.portlet.PortletException: java.lang.NoSuchMethodError: org.apache.poi.util.IOUtils.toByteArray(Ljava/io/InputStream;)[B
at com.liferay.portal.kernel.portlet.LiferayPortlet.callActionMethod(LiferayPortlet.java:166)
at com.liferay.util.bridges.mvc.MVCPortlet.callActionMethod(MVCPortlet.java:247)
at com.liferay.portal.kernel.portlet.LiferayPortlet.processAction(LiferayPortlet.java:78)
at com.liferay.util.bridges.mvc.MVCPortlet.processAction(MVCPortlet.java:210)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:71)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:112)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at cationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:604)
at com.liferay.portlet.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:649)
at com.liferay.portlet.InvokerPortletImpl.processAction(InvokerPortletImpl.java:312)