Link to home
Start Free TrialLog in
Avatar of fhlio_admin
fhlio_adminFlag for United States of America

asked on

cffile write error

I am trying to write a simple file issue.  See the attached code.  The problem is that sometimes it will allow me, sometimes it won't.

When it doesn't I get the following:

***************************************************************************************************************************************
***************************************************************************************************************************************


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

Error Occurred While Processing Request  
An error occurred when performing a file operation write on file \\myserver\D\Intranet\TechFolder\Test\NewExcel.xls.  
The cause of this exception was: java.io.FileNotFoundException: \\myserver\D\Intranet\TechFolder\Test\NewExcel.xls (Access is denied).  
 
The error occurred in D:\Intranet\TechSupport\TestFileWriting.cfm: line 9
 
7 :             </tr>
8 :             </table>
9 : " addnewline="Yes">
10 :             

 

--------------------------------------------------------------------------------
 
Resources:
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 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Remote Address   192.168.10.70
Referrer    
Date/Time   27-Jan-09 11:00 AM
 
Stack Trace (click to expand)  
at cfTestFileWriting2ecfm367057022.runPage(D:\Intranet\ TechFolder\TestFileWriting.cfm:9) at cfTestFileWriting2ecfm367057022.runPage(D:\Intranet\ TechFolder\TestFileWriting.cfm:9)


java.io.FileNotFoundException: \\myserver\D\Intranet\TechFolder\Test\NewExcel.xls (Access is denied)
      at java.io.FileOutputStream.open(Native Method)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
      at coldfusion.tagext.io.FileTag.createNewFile(FileTag.java:1103)
      at coldfusion.tagext.io.FileTag.write(FileTag.java:356)
      at coldfusion.tagext.io.FileTag.doStartTag(FileTag.java:291)
      at coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1915)
      at cfTestFileWriting2ecfm367057022.runPage(D:\Intranet\TechSupport\TestFileWriting.cfm:9)
      at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
      at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
      at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
      at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:225)
      at coldfusion.filter.PathFilter.invoke(PathFilter.java:86)
      at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:69)
      at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
      at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
      at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
      at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
      at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:115)
      at coldfusion.CfmServlet.service(CfmServlet.java:107)
      at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:78)
      at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
      at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
      at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
      at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
      at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
      at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:318)
      at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)
      at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:264)
      at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

 
***************************************************************************************************************************************
***************************************************************************************************************************************
 
I don't see how it can be a permissions issue.  Nothing changes from erring to working as it pertains to users or as it pertains to roles.

We have recently changed from a Windows Server 2000 to Windows Server 2003.

As stated THIS DOES WORK... when it wants to.  But it doesn't work.  No anomalies can be found.

Thanks!!
<cffile action="write" file="\\myserver\D\Intranet\TechFolder\Test\NewExcel.xls" output="
		<table>
		<tr>
			<td  colspan='2'>Item One</td>
			<td  colspan='2'>Item Two</td>
			<td  colspan='2'>Item Three</td>
		</tr>
		</table>
" addnewline="Yes">

Open in new window

Avatar of duncancumming
duncancumming
Flag of United Kingdom of Great Britain and Northern Ireland image

You should wrap this cffile inside a cflock.  And put all that inside a cftry for good measure.

Could there ever be an instance of the code trying to write the same file simultaneously?  e.g. if two users accessed the same code, or if the file looped when you weren't expecting to.  


Avatar of Jones911
Jones911

Do u have the file open while your trying to write to it?  The file is most likely locked for writing at the time you are attempting to write.
Avatar of fhlio_admin

ASKER

duncancumming -  The attached code returns failed.

Jones911 - The code below is separate from the application.  There is a 0.0001% chance that someone is actually trying the same test on our server.

<cftry>
<cflock timeout="10">
<cffile action="write" file="\\myserver\D\Intranet\TechFolder\Test\NewExcel.xls" output="
		<table>
		<tr>
			<td  colspan='2'>Item One</td>
			<td  colspan='2'>Item Two</td>
			<td  colspan='2'>Item Three</td>
		</tr>
		</table>
" addnewline="Yes">
</cflock>
<cfcatch>
Failed
</cfcatch>
</cftry>

Open in new window

Inside your cfcatch, put:
<cfdump var="#cfcatch#">

That might give you more of an idea (or it might just repeat the Access is denied information).

duncancumming - I attached a spreadsheet of the verbose error
TestFileWriting.xls
Does the file exist?  Are you trying to over write it?

Perphaps add a random number to the fliename.xls  ie filename9999.xls
You say this problem only happens sometimes, but it sounds like it's happening consistently for you.  Try remove the addnewline attribute.  Check your filepath.  
Jones911 - File does not exist.  This a test piece of code because of a piece of code in a web app that we have is not working.

duncancumming - I compare it to timeouts.  If people are getting timeouts, then it is easy to duplicate the timeout error.  If you resolve the issue behind timeouts (eg you killed an open trans) then it is hard to duplicate the error.  Today we are in the midst of this problem.  Hence the urgency to test this issue while it exists.  I tried removing the addnewline attribute to no avail.  Also putting the UNC in to Windows Explorer returns the appropriate path every time on both the server and local machines.
ASKER CERTIFIED SOLUTION
Avatar of Jones911
Jones911

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Jones911 - The CF User does not change, nor does the roles/permissions change.  By nature of the fact the system DOES work when it wants, we are assuming that the roles are correct.  The network admin has looked at it several times without seeing anything wrong.  He is one of the 3 of us that are scrambling to resolve this today.

Thanks!!
OK just to be sure  what exact user is Coldfusion running as?  system?  the issues seams to me that CF doe not have access to the share.


But as you said it works sometimes?  If it works sometimes then the file must be locked but something else at exactly that moment.  Are you trying to write to the file in only 1 app?
Capture.JPG
Jones911 -

Q: OK just to be sure  what exact user is Coldfusion running as?  system?
A: This would be on the network admin.  I know that we checked this.  Why would this matter if the issue does work sometimes?  Doesn't this mean that the user has sufficient privileges?

Q: If it works sometimes then the file must be locked but something else at exactly that moment.  Are you trying to write to the file in only 1 app?
A: I have stated before there is a 0.0001% chance that someone is actually trying the same test on our server.  This is a lone piece of code that I created apart from our web app because of the web app having issues.
Have you tried resetting CF services since the problem started?
Well your code is totally valid there is no issue with the code itself.  This is why I keep repeating to check all the values and settings.
Avatar of SidFishes
duncancumming - Yes; it works and then stops and works and then stops... no rhyme or reason...
Jones911 - I understand, but we have ruled out as issues.
SidFishes - I am checking with our network admin.  I will have to get back to you on this.

Thanks!!
SidFishes - I checked with our network admin.  The hotfix has been applied.  This is not the issue.
looking at this again...you reference

\\myserver\D\Intranet\TechFolder\Test\NewExcel.xls.  

the erroring template is  D:\Intranet\TechSupport\TestFileWriting.cfm so I'm assuming everything is on the same local machine

make the path D:\Intranet\TechFolder\Test\NewExcel.xls

and see what happens





Or even D:\NewExcel.xls just to try.
In short, this worked, but being cross servers in the app, it is not resolved.  We need to be able to access this via UNC.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If this was an AD Issue, then why does the attached code output:

0
1
<cfdirectory directory="\\myserver\D\Intranet\TechFolder\Test\" name="qryOutput" action="LIST">
<cfoutput>#qryOutput.recordcount#</cfoutput><br />
<cfdirectory directory="D:\Intranet\TechFolder\Test\" name="qryOutput" action="LIST">
<cfoutput>#qryOutput.recordcount#</cfoutput>

Open in new window

firstly...you -need- to set up cf as i've outlined or you are simply not going to have any luck accessing network resources...period. If you don't believe me then search for coldfusion accessing network resources

secondly, your unc path doesn't make sense to me

afaik, you would never put a drive letter in a unc path it should be  \\myserver\Intranet\TechFolder\Test

-except- when using an administrative share in which case it would be \\myserver\D$\Intranet\TechFolder\Test but cf won't be able to access that unless you run it under an admin account.

as for why you are getting 0 returned, it's likely because of permissions or simply the fact that the path doesn't make sense to cf either

I talked to our network admin about this and we looked at the 2000 server that we switched from.  The CF User was setup the same way.

How could it be different now?
UPDATE: I cannot confirm results unless someone can point me to the reason this error is occurring when it didn't on server 2000.
Please take a  screen shot of the user the CF is runnign as.  Ie the same screen shot I posted.  If its running as system then there is your problem.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Jones911 - It is being used by the local account for now.  My question remained as if this was the solution, give me the reason.

SidFishes - Well explained.  I am going to take this to the network admin for application and will respond shortly.

Thanks!!
The reason is that Windows requires user authentication to access remote resources.  The 2000 server may have been an authenticated machine in Activedirectory and the system account of the 2000 machine had access to the remote file server.  I would hazard a guess that somewhere the 2000 machine did have more permissions then the 2003 one which is why you were unable to write to the remote fileserver.
As a qualified expert myself, point distribution is important to me.  Here is the how and why of the distribution.

Jones911 - First identification = 200 points
SidFishes - Explanation of resolution + Explanation of issue = 300 points (150 each)