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

Microsoft Server OSColdFusion LanguageWindows Server 2003

Avatar of undefined
Last Comment
fhlio_admin

8/22/2022 - Mon
duncancumming

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.  


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.
ASKER
fhlio_admin

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

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
duncancumming

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).

ASKER
fhlio_admin

duncancumming - I attached a spreadsheet of the verbose error
TestFileWriting.xls
Jones911

Does the file exist?  Are you trying to over write it?

Perphaps add a random number to the fliename.xls  ie filename9999.xls
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
duncancumming

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.  
ASKER
fhlio_admin

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
Jones911

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
fhlio_admin

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!!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Jones911

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
ASKER
fhlio_admin

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.
duncancumming

Have you tried resetting CF services since the problem started?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Jones911

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.
SidFishes

ASKER
fhlio_admin

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!!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
fhlio_admin

SidFishes - I checked with our network admin.  The hotfix has been applied.  This is not the issue.
SidFishes

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





Jones911

Or even D:\NewExcel.xls just to try.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
fhlio_admin

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
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
fhlio_admin

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

SidFishes

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

Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER
fhlio_admin

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?
ASKER
fhlio_admin

UPDATE: I cannot confirm results unless someone can point me to the reason this error is occurring when it didn't on server 2000.
Jones911

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.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
fhlio_admin

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!!
Jones911

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.
ASKER
fhlio_admin

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)
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER
fhlio_admin