I am trying to:
I have had this working before, and now all of a sudden i get the following error:
java.lang.NoSuchMethodError: org.apache.poi.xwpf.usermodel.XWPFHyperlinkRun.
This occurs when i put the .war file on an Amazon EC2 server. (all other libraries work fine)
Here are the libraries that i use:
fr.opensagres.xdocreport.converter.odt.odfdom (v 1.0.4)
fr.opensagres.xdocreport.template.freemarker (v 1.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)
Is there anything wrong with my libraries? or is this just a server deployment issue?
Very thankful for help.
Below is my code:
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;
}
Ok i finally got to a solution that worked for me, since this post has alot of views and no answers, i'll answer it myself for those who are in need!
I changed the version of all libraries that has anything to do with "apache.poi" to version 1.0.4
After that i used org.apache.poi version 3.9 instead of 3.11
So finally, to wrap it up... this is what i used in the end
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