This discussion is archived
1 2 3 Previous Next 31 Replies Latest reply: Jun 5, 2008 11:27 AM by 807591 RSS

File.Open Access Denied Error

807591 Newbie
Currently Being Moderated
I am trying to open a .wmv file from my Java program (non-applet). When I double click it, it is throwing an access denied exception. The default application for .wmv's is set to be Windows Media Player. I do not understand why the exception is getting thrown. Is there any workaround for it throwing this exception?
  • 1. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    rmalina wrote:
    I am trying to open a .wmv file from my Java program (non-applet). When I double click it, it is throwing an access denied exception. The default application for .wmv's is set to be Windows Media Player. I do not understand why the exception is getting thrown. Is there any workaround for it throwing this exception?
    The JVM is invoked under a certain user. Does the user invoking the JVM have read access to the .wmv file?
  • 2. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    Yes. Since I am only running the program on the loopback IP, the Java user defaults to me. I am an administrator on the system with read and write access for the file.
  • 3. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    It's probably going to be helpful to post the code you're using. Don't give us everything, but give us what's relevant.
  • 4. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    GIve me a minute, I am trying to figure out which part of the code would be most useful.
  • 5. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    The part with File.Open would be useful (given that there is no open method for the java.io.File class). Give us the code surrounding the line which generates the error. You can find that information in the stack trace of the exception.

    Edit: More context would be nice, too. Windows/Linux/Mac/Solaris? Give us all the dirty details. Particularly your use of networking in this app.

    Edited by: endasil on 5-Jun-2008 2:14 PM
  • 6. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    rmalina wrote:
    Yes. Since I am only running the program on the loopback IP
    eh? loopback IP?
  • 7. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    public void Open(Component rcEventSource)
         {
              //     Purpose:          Open the file.
    
              // the file we want opened
              CLocalFile fOpenFile = this;
    
              // create a temp string that we can use to test
              String sTemp = fOpenFile.GetAbsFileName();
              sTemp = sTemp.toUpperCase();
    
              // if the path ends with a .lnk extension (this is a shortcut)
              if (sTemp.endsWith(".LNK")) {
    
                   // create the link
                   CWindowsLink fLink = new CWindowsLink(fOpenFile.GetFile());
    
                   // if valid
                   if (fLink != null) {
    
                        // reset the file to open to the shortcut's destination
                        fOpenFile = CLocalFile.CreateFile(fLink.GetPath());
                   } // if
              } // if
    
              // if valid
              if (fOpenFile != null) {
    
                   // if this is a directory
                   if (fOpenFile.IsDirectory()) {
    
                        // if we have a target
                        if (rcEventSource != null) {
    
                             // create an event object
                             CRhinoEvent rEvent = new CRhinoEvent(rcEventSource, IEventConsts.ON_LOCAL_OPEN_DIR, fOpenFile);
    
                             // post the command to the main thread
                             CRhinoEventQueue.PostEvent(rEvent);
                        } // if
                        else if (CRhinoMainPanel.GetDebugLogger() != null)
                             // ASSERT:  Programming error, rcEventSource = null
                             CRhinoMainPanel.GetDebugLogger().Info("ASSERT:  Programming error, rcEventSource = null");
                   } // if
                   else {
    
                        // get the file path
                        String sAbsPath = fOpenFile.GetAbsFileName();
    
                        // make it all back slashes
                        sAbsPath = CString.MakeBackSlashes(sAbsPath);
    
                        // replace all back slashes with the file separator
                        sAbsPath = sAbsPath.replace('\\', File.separatorChar);
    
                        // catch exceptions
                        try {
    
                             // try to launch the URL in the default browser
                             Desktop.getDesktop().open(new File(sAbsPath));
                        } // try
                        catch (IOException ioe) {
    
                             // trace
                             System.err.println("Error in trying to open the file (" + sAbsPath + ") in the default application.");
    
                             // log it
                             if (CRhinoMainPanel.DEBUG)
                                  ioe.printStackTrace();
                        } // catch
                   } // else
              } // else
         } // Open
    It is throwing the exception every time (catch IOException ioe). Here is the exception notice:

    Error in trying to open the file (C:\temp2\2007-05-09.wmv) in the default application.
    java.io.IOException: Failed to open file:/C:/temp2/2007-05-09.wmv. Error message: Access is denied.

    Edited by: rmalina on Jun 5, 2008 11:26 AM
  • 8. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    I am doing remote file access, but instead of doing it over a connection, I am connecting to my own computer via the loopback ip (127.0.0.1). The login has a global systems administrator level, so the read/write access should not be a problem. The wmv files are the only ones giving me a problem, so I assumed it was that they had not been set to a given program, but I checked the files, and they were all defaulted to Windows Media Player.
  • 9. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    rmalina wrote:
    I am doing remote file access,
    "Hmmmmm", cotton remarked, mainly to himself.
  • 10. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    I'm running the program in Windows. And I am programming it on NetBeans 6.0.1
  • 11. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    rmalina wrote:
    I am doing remote file access, but instead of doing it over a connection, I am connecting to my own computer via the loopback ip (127.0.0.1). The login has a global systems administrator level, so the read/write access should not be a problem.
    That's still over a connection. It's probably still being socketed. I'm not going to look at your code until you place it between code tags (use
     before and after the code).  I haven't replied to your post so you should be able to edit the post with your code.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  • 12. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    I fixed the code tags.
  • 13. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    First things first, get rid of every comment you have in your code. None of them are useful, and every last one of them makes your code harder to read.

    Second, I'm not sure what all this CLocalFile stuff is, but it's seemingly unrelated to your problem, so we'll ignore that.

    Anyway, so the documentation for Desktop.open(File) says that an IOException will be thrown if the associated application fails to be launched or the specified file has no associated application. So we'll concentrate on that. You're absolutely certain that the permissions of the Java user permit the launching of external programs?
  • 14. Re: File.Open Access Denied Error
    807591 Newbie
    Currently Being Moderated
    Guaranteed. I have been able to open any other program. The .wmv files are the only things throwing the exception.
1 2 3 Previous Next