Page 1 of 1

Ole insertion fails with POI 3.15 version

PostPosted: Tue Nov 08, 2016 10:27 pm
by AnilV
Our product is currently using POI-3.15.jar. As plutext internally uses POI library we are getting an exception due to the removal of a method(putShort) in latest version of POI.
We are using 3.2.0 version of docx4j and plutext.

below method is used for pdf insertion into document as OLE object.

com.plutext.ole.pdf.PdfOleHelperDocx pdfOleHelper = new com.plutext.ole.pdf.PdfOleHelperDocx(mlPackageWriteOnly2);
pdfOleHelper.embedUsingImage(bytes, -1, imageBytes);

Logs:
Caused by: java.lang.NoSuchMethodError: org.apache.poi.util.LittleEndian.putShort([BS)V
at com.plutext.ole.stream.ObjInfo.getOutputStream(ObjInfo.java:136)
at com.plutext.ole.OleObjectBinaryPartHelper.objInfoRepresentAsIcon(OleObjectBinaryPartHelper.java:300)
at com.plutext.ole.pdf.PdfUtils.addPDF(PdfUtils.java:34)
at com.plutext.ole.pdf.PdfOleHelperDocx.ole(PdfOleHelperDocx.java:191)
at com.plutext.ole.pdf.PdfOleHelperDocx.embedUsingImage(PdfOleHelperDocx.java:133)
at com.plutext.ole.pdf.PdfOleHelperDocx.embedUsingImage(PdfOleHelperDocx.java:104)

Below method is removed from POI-3.15

public static void putShort( byte[] data, short value )
{
putShort( data, 0, value );
}


From docx4j 3.3.0 version, looks like the dependency on POI library is removed. Is this right?

What would you suggest to fix the above ole embedding issue. Please let us know.

Re: Ole insertion fails with POI 3.15 version

PostPosted: Wed Nov 09, 2016 7:36 am
by jason
AnilV wrote:From docx4j 3.3.0 version, looks like the dependency on POI library is removed. Is this right?

What would you suggest to fix the above ole embedding issue. Please let us know.


Yes, docx4j v3.3.0 removes the POI dependency.

So the recommended approach would be to move to v3.3.x

Alternatively, you could potentially use https://maven.apache.org/plugins/maven-shade-plugin/ to shade - i.e. rename - the packages of docx4j's POI deps in v3.2.0.

And other workarounds spring to mind. But yes, best to move to 3.3.x