mardi 24 février 2015

Error from Word Extractor

I am extracting text from various document files like doc, docx etc. using apache poi. My code is running well in Windows, but after deploying to test server it's not working.


Server OS: Amazon Linux Env.: AWS


Here is my code snippet:



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


I am getting this error:



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)




Aucun commentaire:

Enregistrer un commentaire