Skip to main content
Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.

POIUtility - Object Instantiation Exception

By Ben Nadel on
Tags: ColdFusion

Every now and then, I get people contacting me about problems using my POIUtility.cfc. They are usually getting this error:

Object Instantiation Exception. An exception occurred when instantiating a java object.

While I think there might be several reasons that this object instantiation could occur, usually, with the POI Utility ColdFusion component, I find that it is due to the file path that's being used. The POI Utility requires a full file path. This means that you should be using something like ExpandPath( FILE ) when defining your file path. Running this code:

<cfset objSheet = objPOIUtility.ReadExcel(
	FilePath = "meals.xls"
	) />

... will throw that object instantiation error since "meals.xls" is not a full path. However, running this code, with the full path, will not throw any error and will work just fine:

<cfset objSheet = objPOIUtility.ReadExcel(
	FilePath = ExpandPath( "meals.xls" )
	) />

Hope that helps with people having this problem.

Reader Comments

Heh, every time my project manager has an old copy of a site moved or cloned and doesn't remember to open up the settings file and re-adjusts paths, I get a "Hey... can you look into this Object Instantiation Error?" I send an email back saying, "Hey, did you fix the temp/library paths?"

...? When you're making the big bucks and you're at the top of the food chain like, Mr. Nadel, Chief Technology Officer, wouldn't you have managers?

Ive also received that error when i have the dang xls file open on my browser. This only occurs when i try to read in a file. Simple solution to that problem.

When I use this cfc and the ziputility cfc, I get the same errors around the area that the path is used to instantiate the file input stream:

<cfset LOCAL.FileInputStream = CreateObject(
) />

I'm using a full path for both pieces of code:


Any clues?

Thanks and happy Friday!


If you do this:

#FileExists( "d:\inetpub\directoryname\anotherdirectoryname\" )#

... what does it give you?

It creates the zip drive but it's when it tries to add the files, it chokes. I imagine on filepath.

exact line of zipUtility is 282:

<cfset LOCAL.FileInputStream = CreateObject(
) />


I am not sure what the problem is. Sorry I cannot be more help on this. It looks like you simply cannot create the file stream. The only reason I have come across on this is that the file doesn't exist or is an invalid path or something.

Here is the full error without the full paths for security reasons... The zip file gets created and is 1k but it barfs on adding files to the stream....

Any clues on even how to debug this myself would be great. I am not a java child. I know my CF ok but not java...

Thanks so much!

The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.

The following information is meant for the website developer for debugging purposes.

Error Occurred While Processing Request
Object Instantiation Exception.
An exception occurred when instantiating a java object. The cause of this exception was that: .

The error occurred in ...cfc\ZipUtility.cfc: line 286
Called from ...OpptyImportBackend.cfm: line 186
Called from ...OpptyImportBackend.cfm: line 169
Called from ...OpptyImportBackend.cfm: line 1
Called from ...cfc\ZipUtility.cfc: line 286
Called from ...OpptyImportBackend.cfm: line 186
Called from ...OpptyImportBackend.cfm: line 169
Called from ...OpptyImportBackend.cfm: line 1

284 : ""
285 : ).Init(
286 : GetFileFromPath(LOCAL.FilePath)
287 : ) />
288 :


Check the ColdFusion documentation to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.

Browser Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705; .NET CLR 2.0.50727; InfoPath.1)
Remote Address
Referrer https://.../OpptyImportWizardMapping.cfm
Date/Time 22-Oct-07 09:02 AM

Stack Trace (click to expand)
at cfZipUtility2ecfc1962888858$funcCOMPRESS.runFunction(...cfc\ZipUtility.cfc:286) at cfOpptyImportBackend2ecfm376580135._factor5(...OpptyImportBackend.cfm:186) at cfOpptyImportBackend2ecfm376580135._factor6(...OpptyImportBackend.cfm:169) at cfOpptyImportBackend2ecfm376580135.runPage(...OpptyImportBackend.cfm:1) at cfZipUtility2ecfc1962888858$funcCOMPRESS.runFunction(...cfc\ZipUtility.cfc:286) at cfOpptyImportBackend2ecfm376580135._factor5(...OpptyImportBackend.cfm:186) at cfOpptyImportBackend2ecfm376580135._factor6(...OpptyImportBackend.cfm:169) at cfOpptyImportBackend2ecfm376580135.runPage(...OpptyImportBackend.cfm:1)

at sun.reflect.GeneratedConstructorAccessor274.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at coldfusion.runtime.CfJspPage._invoke(
at cfZipUtility2ecfc1962888858$funcCOMPRESS.runFunction(...cfc\ZipUtility.cfc:286)
at coldfusion.runtime.UDFMethod.invoke(
at coldfusion.filter.SilentFilter.invoke(
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(
at coldfusion.filter.FunctionAccessFilter.invoke(
at coldfusion.runtime.UDFMethod.runFilterChain(
at coldfusion.runtime.UDFMethod.invoke(
at coldfusion.runtime.TemplateProxy.invoke(
at coldfusion.runtime.TemplateProxy.invoke(
at coldfusion.runtime.CfJspPage._invoke(
at cfOpptyImportBackend2ecfm376580135._factor5(...OpptyImportBackend.cfm:186)
at cfOpptyImportBackend2ecfm376580135._factor6(...OpptyImportBackend.cfm:169)
at cfOpptyImportBackend2ecfm376580135.runPage(...OpptyImportBackend.cfm:1)
at coldfusion.runtime.CfJspPage.invoke(
at coldfusion.tagext.lang.IncludeTag.doStartTag(
at coldfusion.filter.CfincludeFilter.invoke(
at coldfusion.filter.ApplicationFilter.invoke(
at coldfusion.filter.PathFilter.invoke(
at coldfusion.filter.ExceptionFilter.invoke(
at coldfusion.filter.BrowserDebugFilter.invoke(
at coldfusion.filter.ClientScopePersistenceFilter.invoke(
at coldfusion.filter.BrowserFilter.invoke(
at coldfusion.filter.GlobalsFilter.invoke(
at coldfusion.filter.DatasourceFilter.invoke(
at coldfusion.filter.RequestThrottleFilter.invoke(
at coldfusion.CfmServlet.service(
at coldfusion.bootstrap.BootstrapServlet.service(
at jrun.servlet.ServletInvoker.invoke(
at jrun.servlet.JRunInvokerChain.invokeNext(
at jrun.servlet.JRunRequestDispatcher.invoke(
at jrun.servlet.ServletEngineService.dispatch(
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(
Caused by: SOBAccreditations200710Mon.xls (The system cannot find the file specified)
at Method)
... 43 more

Oooh, I see. Ok, that makes sense. Yeah, right now, you have to add one at a time. But, that is a cool idea to do a list.

Hi Ben,
on some Excel files i get the message Object Instantiation Exception. An exception occurred when instantiating a java object, too.
I tried with expandpath(), but with no success. Now i have downloaded the new version of jarkarta Poi, version 3 on
I deleted the old poi files files on the coldfusion lib directory, poi-2.5.1-final-20040804.jar, poi-contrib-2.5.1-final-20040804.jar and replaced them with the new version poi-3.0-rc4-20070503.jar and poi-contrib-3.0-rc4-20070503.jar. After restarting the coldfusion server, i can read my Excel files with POIUtility.cfc.

the error:

Object Instantiation Exception.
An exception occurred when instantiating a java object. The cause of this exception was that: .

The error occurred in ...\POIUtility.cfc: line 883


881 : "org.apache.poi.hssf.usermodel.HSSFWorkbook"
882 : ).Init(
883 : LOCAL.ExcelFileSystem
884 : );
885 :


The system should not matter, as far as I know. I am on a Windows system and it works fine. Can you post the few lines of code that actually creates the POIUtility? ... The CreateObject() lines.


Interesting. I wonder why it was working in some files and not for others. Maybe it was just a bug in the Java code, seeing as the new release fixed it. Thanks for sharing that the new version works.

<cfset objPOI = CreateObject("component", "POIUtility" ).Init() >

<cfset arrSheets = objPOI.ReadExcel( FilePath = tempFile , HasHeaderRow = true ) >


It crashes at cfset arrSheets with the error I posted.

All I need it for right now is to read in a sheet name.

I also tried the simple code below but it crashes at cfset wb with the same error. I am on a windows server 2003 enterprise edition...


Object Instantiation Exception.
An exception occurred when instantiating a java object. The cause of this exception was that: .


<cfset fileIn = createObject("java","").init("#tempFile#")/>

<cfset fs = createObject("java","org.apache.poi.poifs.filesystem.POIFSFileSystem").init(fileIn)/>

<cfset wb = createObject("java","org.apache.poi.hssf.usermodel.HSSFWorkbook").init(fs)/>
<cfset sheet = wb.getSheetAt(0)/>

Any ideas would be helpful:>)


Just to let everyone know, I had the same issue with POI not accepting Excel files where the top row was using filtering, In Excel 2007 (using the old XLS format) I just went to data and unticked "filter" and all worked ok, not sure if filtering is ok on other rows, didn't try it

This error
Object Instantiation Exception. An exception occurred when instantiating a java object

also happen if an Excel file has auto-filter on a column.

Hope this help someone.

Object Instantiation Exception Error.

Can anyone tell me how to remove or skip auto-filtering in excel using coldfusion. Found that the page has auto-filtering, but dont know exactly what to do. please help me. I need to fix this badly.

Thanks & regards.


From what I have read, this is a bug in the underlying POI Java library. I believe it is a filed bug and they are in the process of trying to fix it (I assume). And, since my tags just sit on top of the Java library, there is nothing that I can do about it.

Hi All

Thanks for ur reply Ben. I have two issues now.
1. As u know stacy some how managed to overcome the Object Instantiation Exception. by updating the new versions of poi-3.0...jar files into the lib of server. But i don't know how & wahere to update.

2. Can i use a file path like '' in the
<cfset strFilePath = ExpandPath( "#url.file#" ) /> where
url.file = ''

This is because i have to download a excel file from the ftp directory directly & feed the database.
It gives me an error at this line.

LOCAL.FileInputStream = CreateObject( "java", "" ).Init( ARGUMENTS.FilePath );

Please help me in these issues. I would be very thankfull to u.



You cannot go directly from FTP to Excel, at least not yet. You would need to save the file locally first, then read it into via POI.


Error: Object Instantiation Exception.

I did update the poi 3.0...jar files to the server lib. But still i get the Object Instantiation Exception. I am able to read and upload the excel file after deleting the first row (which should have a filter). But without deleting i am not able to. Is there any other solution.

Can anyone help me to get this fixed. I have been trying this for days nw. Please contact me on if u can guide me to get this rid off.

Thanks a lootttt !

Just a quick tip to anyone researching the 'Object Instantiation Exception' message (like I was a few minutes ago!) - Don't forget to check file permissions, especially on a *nix server - that was the root of my problem.

We now return you to your regular program! B->

All the best



First of all, thank you for your site. I have learned a ton from reading your entries.

I am using your POIUtility.cfc amd have run into an issue with object instantiation. I thought it was a path issue, but I used the file exists function and it returned yes.

The error is tripping at the following code...

<cfset arrExcel = objPOIUtility.ReadExcel(
FilePath = strFilePath,
HasHeaderRow = true,
SheetIndex = 0
) />

I have validated strFilePath, which is a valid path. Is there something I need to do on the server side or anything? Any help would be appreciated. If you need any more info, let me know.


What happens if you open up the target file in Excel and re-save it. If it works at that point, then there is something "odd" about the target file. Sometimes, if an Excel file is generated by a different 3rd party app, it has some features that don't jive with the POI library. usual, you are spot on. I opened it up, did a save as, re-uploaded and voila'...the magic of POI unfolded!

So it will be a good practice to do a save as from now on...thanks again for the assist and keep on coding!


It depends on where the document is coming from. Someone, a while back, discovered that POI can only deal with documents who's size is like a multiple of 255 B or something like that (I don't remember the exact number). Apparently, Excel will do this naturally, but 3rd party apps might not, so they bomb out when being read in via POI.

Where did this Excel document come from?

The document was exported from a 3rd party online surveying product. It was an excel export of their results.

I'm researching the same thing and have one extra bit to add: it appears that the POI system can't read older (Excel 5.0) formatted files. If I save one of Ben's sample XLS files in the "Excel 5.0/95" format, I get this error. I do not know if the newer POI fixes this, but since I'm running on a shared environment, it's not likely to help me anyway.

Confusing the waters a bit more, my Open Office lists Excel 5.0 and Excel 95 as two different formats but Excel itself lists them together. I guess the point is 97/2000/XP works, older doesn't.

This might be why some people have success when they do a Save As.


Hmmm, interesting. I have not dealt much with the open office documents at all. Honestly, I haven't even really dealt much with the latest POI Java package yet.


I'm using your latest POIUtility.cfc along with all of the latest supporting files. Things are working very well when converting an Excel xx-2003 file (read: .xls). However, when I attempt, using the exact same code, to make the conversion on a Excel 2007 file (.xlsx) I end up getting the Object Instantiation Exception.

I've scoured the web for possible causes, moved files around, and I've come up with nothing. Any ideas?

Thanks in advance,


The problem is that the POI JAR file that ships with ColdFusion CF8 and earlier is *not* the most recent POI package. If you overwrite your JAR file with the newest one (or load it was a URL Class Loader), it should work with 2007 XLS files.

I am getting an Object Instantiation Exception.
Class not found: org.apache.poi.xssf.usermodel.XSSFWorkbook when trying to read a .xlsx file with the modified POIUtility.cfc. I have updated the jar files in CF8 to the 3.6 version and my file path is correct to the .xlsx file. Any ideas why this may be happenning?


You may need to include the poi-ooxml-3.6.jar, and the other jars which come packaged from

Sorry, comments have been temporarily disabled due to spam. I'm busy implementing a new moderation feature because... some people are terrible!