Mike, you can see the classes and libraries loaded within CF using the 
“Settings Summary” page of the CF admin, which has two fields: “CF Server Java 
Class Path” and “Java Class Path”, each listing all the classes and 
jars/libraries. This is quite different from the “java and jvm” page of the 
Admin (not available in Multiserver deployments), as that offers a “coldfusion 
classpath” field which may well be blank: it’s where one can add to the 
classpath of what CF already knows/uses.  (There are also java API methods you 
could call programmatically to get the classpath values.)

The order in which classes are found is by the JVM searching through these 
classpaths, in order (I’m not sure if with CF it searches the “CF Server class 
path” before the “java class path”, but I would suspect so.)

If I were to guess, then as Dawn has suggested, it seems likely that your error 
is caused by a class conflict. I realize you’re using javaloader, and that is 
supposed to enable per-request class loading. I just wonder if when you called 
“org.apache.poi.xssf.usermodel.XSSFWorkbook”, then IT may turn around and call 
for some other class, which it may find in another of the libraries in the 
classpath.  Just a guess.

You may even want to contact Mark Mandel or see if there’s a google group or 
forum for javaloader, where perhaps a similar problem may have been discussed 
(don’t look for a discussion necessarily of this exact POI class, of course). 

HTH.

 

/charlie

 

From: [email protected] [mailto:[email protected]] On Behalf Of Mike Staver
Sent: Thursday, November 24, 2011 11:48 AM
To: [email protected]
Subject: Re: [ACFUG Discuss] JavaLoader & POI Issue

 

Interesting. Since I'm using the same code on two different systems and getting 
the same results - is there any way I can see what is loaded in memory 
currently?

-Mike


On Nov 24, 2011, at 7:46 AM, Dawn Hoagland <[email protected]> wrote:

I've seen this happen when multiple versions of the library are being loaded 
into memory.  CF/Java SHOULD pick the one loaded with the Javaloader, but 
doesn't always. I've seen this happen when multiple versions of POI have been 
dropped in CF's lib folder as well.  When stuff like this happens, I write/test 
in java only to eliminate issues with POI.

 

On Wed, Nov 23, 2011 at 9:35 PM, Mike Staver <[email protected]> wrote:

I've always been able to use POI via JavaLoader to read in standard xls files 
and extract data out of the cells for whatever I want, like storing in a 
database. Recently, I've had to start coding to handle Office 2007 file formats 
like xlsx and xlsm. POI 3.5 and higher should be able to do that according to 
many examples I've found on the internet and in Apache's own documentation. So, 
I'm currently using ColdFusion 9, JavaLoader 1.0, and POI 3.8b4. For the 
record, I've also tried POI 3.6 and 3.7 for this test and sample code below. 
Here is my sample code:

<cfoutput>
<cfset var.JLKey = "93345778-4949-4705-1235577891134557" />
<cfset var.paths = []>
<cfset var.jarpath = "/Users/mstaver/workspace/Fimble/ExternalCode" /> <!--- 
location of POI jars --->
<cfdirectory action="list" name="files" directory="#var.jarpath#" 
filter="*.jar" recurse="true" />

<cfloop query="files">
    <cfset arrayAppend(var.paths, directory & "/" & name) />
</cfloop>

<cfif NOT structKeyExists(server, var.JLKey)>
    <cfset server[var.JLKey] = createObject("component", 
"component.JavaLoader").init(loadPaths=var.paths, 
loadColdFusionClassPath=false) />
</cfif>

<cfscript>
fileAndPath = "/Users/mstaver/workspace/Fimble/11g.xlsm";
inp = createObject("java", "java.io.FileInputStream").init("#fileAndPath#");
objWorkBook = 
server[var.JLKey].create("org.apache.poi.xssf.usermodel.XSSFWorkbook").Init(inp);
</cfscript>

</cfoutput>

When I write use this code with one small tweak (HSSF instead of XSSF) and I 
feed in an xls file, everything works as expected. However, when I use the 
exact code above and feed it xlsx or xlsm, I get this error:


Object instantiation exception. 


An exception occurred while instantiating a Java object. The class must not be 
an interface or an abstract class. Error: ''.   The error occurred in 
/Users/mstaver/workspace/Fimble/test.cfm: line 18
Called from /Users/mstaver/workspace/Fimble/Application.cfc: line 97
Called from /Users/mstaver/workspace/Fimble/test.cfm: line 18
Called from /Users/mstaver/workspace/Fimble/Application.cfc: line 97

16 : fileAndPath = "/Users/mstaver/workspace/Fimble/11g.xlsm";
17 : inp = createObject("java", 
"java.io.FileInputStream").init("#fileAndPath#");
18 : objWorkBook = 
server[var.JLKey].create("org.apache.poi.xssf.usermodel.XSSFWorkbook").Init(inp);


Further down the error stack, I think this is relevant:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class 
org.apache.poi.openxml4j.opc.internal.unmarshallers.PackagePropertiesUnmarshaller


I don't know where to go on this one. I've tried the SS method, instead of XSSF 
- and it works fine, until I feed it an xlsx or xlsm again. I don't get it. 
I've also tried this on Windows 2003, besides here on my Macbook. Both machines 
are running CF 9.0.1. I'm getting the impression that I'm missing a class or 
something. I've followed examples from all over the web, and from the POI docs. 
Everything works until I feed it Office 2007 format docs...


------------------------------------------------------------- 
To unsubscribe from this list, manage your profile @ 
http://www.acfug.org?fa=login.edituserform 

For more info, see http://www.acfug.org/mailinglists 
Archive @ http://www.mail-archive.com/discussion%40acfug.org/ 
List hosted by FusionLink <http://www.fusionlink.com>  
------------------------------------------------------------- 





 

-- 
Dawn




-------------------------------------------------------------

To unsubscribe from this list, manage your profile @ 

http://www.acfug.org?fa=login.edituserform



For more info, see http://www.acfug.org/mailinglists

Archive @ http://www.mail-archive.com/discussion%40acfug.org/

List hosted by http://www.fusionlink.com

-------------------------------------------------------------


Reply via email to