Access is denied

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • OPERATING SYSTEM(S) Windows XP FULL JDK VERSION(S): java version "1.5.0_04" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05) Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode) DESCRIPTION: When running the following testcase, the createTempFile call occassionally throws an IOException "Access is denied". import; public class TestFile { public static void main(String[] args) throws Exception { for (int i = 0; i < 5; i++) { File tempFile = File.createTempFile("WSTMPCC", null, null); System.out.println("*** create = " + tempFile.getAbsolutePath() + " ***"); tempFile.delete(); System.out.println("*** delete = " + tempFile.getAbsolutePath() + " ***"); tempFile.mkdir(); System.out.println("*** mkdir = " + tempFile.getAbsolutePath() + " ***"); tempFile.mkdir(); } } } C:\dev\test>java TestFile Exception in thread "main" Access is denied at Method) at at at TestFile.main( What appears to be happening is that createTempFile generates a temporary filename and then attempts to create a new empty file with that name using the CreateFileW OS call. If a directory already exists with that name, CreateFileW appears to be returning an error of ERROR_ACCESS_DENIED, which is being treated as an error. What should be happening is that the class libraries should be generating a new temporary filename and trying again. Looking at the MSDN documentation for CreateFileW, I'm not certain that ERROR_ACCESS_DENIED cannot be thrown in other circumstances, so I do not believe it is safe to simply ignore that error and retry as we currently do for ERROR_FILE_EXISTS. Instead a test could be made before CreateFileW is called to test if the generated filename already exists and if it does abort such that a new filename can be generated and the attempt to create a new empty file repeated. [This bug is being submitted as a courtesy, in order to maintain uniformity between Sun & IBM JDKs. It has been fixed in IBM JDKs. Please contact ###@###.### if you have questions.]
    via by Erik Larsen,
  • IOException: Access is denied | JBoss Developer
    via by Unknown author,
  • Problems with command dispatch to Windows Node
    via by Serban Alexe,
    • Access is denied at Method) at at at TestFile.main(

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    olle.hallin1 times, last one,
    rp1 times, last one,
    45 more bugmates