Results 1 to 5 of 5
  1. #1
    Bharath_M is offline Member
    Join Date
    Apr 2011
    Posts
    11
    Rep Power
    0

    Default "Access is denied" error while file creation

    Hi Friends,

    I'm getting the below exceptions while trying to create file with my application.

    Please note that,
    - My application has write access to the folder,
    - Target folder isn't read-only,
    - There isn't a folder existing already at the target location with same name as the filename i create

    Still i get this application. One thing i noted is machine restart helps me come out of this problem.

    A standalone program written is able to write file at same application as well..

    Please help me with your thoughts...

    Regards,
    Bharath M
    #java.io.FileNotFoundException: C:\program files\marimba\tuner\.marimba\marimba\ch.23\data\So ftwareUsageOutput\-1792029220.die (Access is denied)
    # at java.io.FileOutputStream.open(Native Method)
    # at java.io.FileOutputStream.<init>(Unknown Source)
    # at java.io.FileOutputStream.<init>(Unknown Source)
    # at com.marimba.apps.inventory.scanner.SoftwareUsageMo nitorScanner.touchFile(SoftwareUsageMonitorScanner .java:574)
    # at com.marimba.apps.inventory.scanner.SoftwareUsageMo nitorScanner.stop(SoftwareUsageMonitorScanner.java :347)
    # at com.marimba.apps.inventory.scanner.ScanEngine.scan (ScanEngine.java:307)
    # at com.marimba.apps.inventory.scanner.Scanner.scan(Sc anner.java:1331)
    # at com.marimba.apps.inventory.scanner.Scanner.start(S canner.java:375)
    # at com.marimba.apps.inventory.scanner.Scanner.access$ 000(Scanner.java:58)
    # at com.marimba.apps.inventory.scanner.Scanner$StartTh read.run(Scanner.java:2107)


    #java.io.IOException: Access is denied
    # at java.io.WinNTFileSystem.createFileExclusively(Nati ve Method)
    # at java.io.File.createNewFile(Unknown Source)
    # at com.marimba.apps.inventory.scanner.DictionaryScann er.scan(DictionaryScanner.java:77)
    # at com.marimba.apps.inventory.scanner.ScanEngine.appD ictionaryScan(ScanEngine.java:1560)
    # at com.marimba.apps.inventory.scanner.ScanEngine.scan (ScanEngine.java:325)
    # at com.marimba.apps.inventory.scanner.Scanner.scan(Sc anner.java:1331)
    # at com.marimba.apps.inventory.scanner.Scanner.start(S canner.java:375)
    # at com.marimba.apps.inventory.scanner.Scanner.access$ 000(Scanner.java:58)
    # at com.marimba.apps.inventory.scanner.Scanner$StartTh read.run(Scanner.java:2107)

  2. #2
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Post

    Try using FilePermission. Give exclusive rights of "write" in the target directory.

  3. #3
    Bharath_M is offline Member
    Join Date
    Apr 2011
    Posts
    11
    Rep Power
    0

    Default

    Thaks for your reply...

    My java policy file has all permissions by default...Will it still make a difference adding FilePermission...

    Below is my policy file...
    // Standard extensions get all permissions by default

    grant codeBase "file:${{java.ext.dirs}}/*" {
    permission java.security.AllPermission;
    };

    // default permissions granted to all domains

    grant {
    // Allows any thread to stop itself using the java.lang.Thread.stop()
    // method that takes no argument.
    // Note that this permission is granted by default only to remain
    // backwards compatible.
    // It is strongly recommended that you either remove this permission
    // from this policy file or further restrict it to code sources
    // that you specify, because Thread.stop() is potentially unsafe.
    // See "http://java.sun.com/notes" for more information.
    permission java.lang.RuntimePermission "stopThread";

    // allows anyone to listen on un-privileged ports
    permission java.net.SocketPermission "localhost:1024-", "listen";

    // "standard" properies that can be read by anyone

    permission java.util.PropertyPermission "java.version", "read";
    permission java.util.PropertyPermission "java.vendor", "read";
    permission java.util.PropertyPermission "java.vendor.url", "read";
    permission java.util.PropertyPermission "java.class.version", "read";
    permission java.util.PropertyPermission "os.name", "read";
    permission java.util.PropertyPermission "os.version", "read";
    permission java.util.PropertyPermission "os.arch", "read";
    permission java.util.PropertyPermission "file.separator", "read";
    permission java.util.PropertyPermission "path.separator", "read";
    permission java.util.PropertyPermission "line.separator", "read";

    permission java.util.PropertyPermission "java.specification.version", "read";
    permission java.util.PropertyPermission "java.specification.vendor", "read";
    permission java.util.PropertyPermission "java.specification.name", "read";

    permission java.util.PropertyPermission "java.vm.specification.version", "read";
    permission java.util.PropertyPermission "java.vm.specification.vendor", "read";
    permission java.util.PropertyPermission "java.vm.specification.name", "read";
    permission java.util.PropertyPermission "java.vm.version", "read";
    permission java.util.PropertyPermission "java.vm.vendor", "read";
    permission java.util.PropertyPermission "java.vm.name", "read";
    permission javax.management.MBeanTrustPermission "register";
    };

    Also, this issue isn't seen across all machines...only on few machines this is being witnessed...

  4. #4
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Smile

    Are you sure you close all the streams and other handles to the file after writing to the file?

    Just check the code and make sure you are closing all the streams.

    Generally, this problem occurs in Windows OS, whereas it runs perfectly fine on most Linux machines.

    Handles to files and Output streams do not get released properly on windows. Linux does that on its own. So, its always better to close/release them once you are done.

  5. #5
    Bharath_M is offline Member
    Join Date
    Apr 2011
    Posts
    11
    Rep Power
    0

    Default

    I don't see my file created, so there should ideally be no handlers for a file that doesn't exist...it fails with this "Access denied" exception even before my file gets created...

Similar Threads

  1. Replies: 6
    Last Post: 02-10-2011, 10:55 AM
  2. Replies: 5
    Last Post: 06-22-2010, 04:51 PM
  3. Replies: 1
    Last Post: 11-20-2009, 08:58 PM
  4. Replies: 2
    Last Post: 01-24-2009, 07:56 PM
  5. Replies: 1
    Last Post: 10-20-2008, 08:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •