问题
<cfscript>
filepath = ExpandPath("./1.ppt");
fis = CreateObject( "java", "java.io.FileInputStream" ).init(filepath);
//initialize slideshow object with input stream
src = createObject("java","org.apache.poi.xslf.usermodel.XMLSlideShow").init(fis);
fis.close();
</cfscript>
I am not able to initialize org.apache.poi.xslf.usermodel.XMLSlideShow object in coldfusion. Getting following error: Unable to find a constructor for class org.apache.poi.xslf.usermodel.XMLSlideShow that accepts parameters of type ( java.io.FileInputStream )
Please help
回答1:
I know you said you are using POI 3.8, but the error message says you are using an older version.
As Antony mentioned, ColdFusion 9 is bundled with an older version (POI 3.5) which is what createObject()
uses. There was no XMLSlideShow(InputStream)
constructor back in version 3.5. Hence the error message.
There are two (2) ways to load a newer version of POI:
Use the JavaLoader to run the newer version in parallel
Replace the existing POI jars in
{cf_root}\lib
. Then restart the CF server. Note: I have not done this personally, so I do not know if doing so will break other features
来源:https://stackoverflow.com/questions/10612042/not-able-to-initialize-org-apache-poi-xslf-usermodel-xmlslideshow-in-coldfusion