Can't rename a file using File.renameTo(...)

Hi,
I have a servlet, RenameFile, that receives audio file via HTTP Post and writes it to /tmp/recording.0002002B-0C0022BB-0001.1.20050622.073208.wav. Then it creates directories under /alert_messages directory based on the timing parameters that it get. Finally, it renames /tmp/recording.0002002B-0C0022BB-0001.1.20050622.073208.wav to /alert_messages/2005/06/22/22/00/79_0_200506222200_001.WAV. RenameFile runs fine when it runs by itself (ONLY one Tomcat, jakarta-tomcat-4.1.30, is running). However, RenameFile fails to rename the /tmp/recording.0002002B-0C0022BB-0001.1.20050622.073208.wav to /alert_messages/2005/06/22/22/00/79_0_200506222200_001.WAV when it runs in a Linux box that jboss-3.2.1_tomcat-4.1.24 is also running. In this box, TWO versions of Tomcat are running at the same time. I set the /alert_messages directory with �chmod �R 777� and run jakarta-tomcat-4.1.30 as tomcat user. RenameFile fails the rename operation. But, it creates the /alert_messages/2005/06/22/22/00/ directories.
It seem like RenameFile can create directory but can�t create file in the /alert_messages directory when both version of tomcats are running at the same time.
Can it be due to both the jakarta-tomcat-4.1.30 and the jboss-3.2.1_tomcat-4.1.24 versions are running at the same time in one Linux box?
Can this be Jboss prevented the operation?
I did not receive any io exception!!!
Any help in this issue is greatly appreciated.
Debug listing from the RenameFile;
- originalFilename: recording.0002002B-0C0022BB-0001.1.20050622.073208.wav
- file.toString(): /tmp/recording.0002002B-0C0022BB-0001.1.20050622.073208.wav
- file.getName(): recording.0002002B-0C0022BB-0001.1.20050622.073208.wav
- file.length(): 122986
- file /alert_messages/2005/06/22/22/00/79_0_200506222200_001.WAV
- file NOT renamed /alert_messages/2005/06/22/22/00/79_0_200506222200_001.WAV
File Listing in the /tmp directory create by RenameFile;
-rw-r--r-- 1 tomcat tomcat 122986 Jun 22 07:33 recording.0002002B-0C0022BB-0001.1.20050622.073208.wav
Directoy Listing in the / directory with �ls �la�;
drwxrwxrwx 3 tomcat tomcat 4096 Jun 22 07:28 alert_messages
Directory created by the RenameFile with �ls -la /alert_messages/2005/06/22/22/00�;
drwxr-xr-x 2 tomcat tomcat 4096 Jun 22 07:33 .
drwxr-xr-x 3 tomcat tomcat 4096 Jun 22 07:33 ..
Out put from catalina.out;
!!!!! Can Read the old File !!!!!!!!!!!!!!!!!!!!
!!!!! Can Write the old File !!!!!!!!!!!!!!!!!!!!
!!!!! Can Not Read the new File !!!!!!!!!!!!!!!!!!!!
!!!!! Can Not Write the new File !!!!!!!!!!!!!!!!!!!!
!!!!! renameTo return false !!!!!!!!!!!!!!!!!!!!
Code That rename a file:
  public synchronized String renameAlertMessageFile(String oldFileName,
                            String newFileName)
            throws SecurityException, NullPointerException
    File oldFile = null;
    File newFile = null;
    String result = null;
    StringBuffer myNewFileName = null;
    boolean renamed = false;
    try {
      int indexStringValue;
      int newFileLength;
      int indexOfPeriod;
      int indexOfLastUnderScore;
      int lengthOfExtension;
      boolean  Contin = true;
      String sNumber = null;
      String indexString = null;
      myNewFileName = new StringBuffer(newFileName);
      oldFile = new File(oldFileName);
      newFile = new File(myNewFileName.toString());
      if (oldFile.canRead() == false) {
        System.out.println(" !!!!!  Can Not Read the old File !!!!!!!!!!!!!!!!!!!!");
      } else {
        System.out.println(" !!!!!  Can Read the old File !!!!!!!!!!!!!!!!!!!!");
      if (oldFile.canWrite() == false) {
        System.out.println(" !!!!!  Can Not Write the old File !!!!!!!!!!!!!!!!!!!!");
      } else {
        System.out.println(" !!!!!  Can Write the old File !!!!!!!!!!!!!!!!!!!!");
      if (newFile.canRead() == false) {
        System.out.println(" !!!!!  Can Not Read the new File !!!!!!!!!!!!!!!!!!!!");
      } else {
        System.out.println(" !!!!!  Can Read the new File !!!!!!!!!!!!!!!!!!!!");
      if (newFile.canWrite() == false) {
        System.out.println(" !!!!!  Can Not Write the new File !!!!!!!!!!!!!!!!!!!!");
      } else {
        System.out.println(" !!!!!  Can Write the new File !!!!!!!!!!!!!!!!!!!!");
      renamed = oldFile.renameTo(newFile);
      if (renamed == false) {
        System.out.println(" !!!!!  renameTo return false !!!!!!!!!!!!!!!!!!!!");
    } catch (NullPointerException ex) {
      // Throw the same exception so that the caller may catch the
      //   exception and log the error
      System.out.println("NullPointerException For The New Dest File Name");
      ex.printStackTrace();
      throw ex;
    } catch (SecurityException seEx) {
      System.out.println("SecurityException For The New Dest File Name");
      seEx.printStackTrace();
      // Throw the same exception so that the caller may catch the
      //   exception and log the error
      throw seEx;
    } finally {
      if (renamed == true)
        return myNewFileName.toString();
      else
        return null;
  } // End renameAlertMessageFile

Hi,
Thank you for replying to my message. The servlet has been running for me for the last 12 months. However, it was running by itself without the Jboss-tomcat running on the same box. Can this be the catalina.policy file in the jboss-tomcat version restricted the rename operation. We are not allowed to write file under the umbrella of J2EE. But the servlet did not run within Jboss-tomcat. This really gets me thinking that something is not working correctly. Perhaps tomcat did not has the permission to write on the /alert_messages directory, again it did created the subdirectories under the /alert_messages.
Any idea of what is going on?

Similar Messages

  • Can We rename BAD File name in SQL Loader

    Hi All,
    Can we rename BAD File name in SQL loader?
    If yes, how?
    Thanks in Advance,
    S

    Hi,
    You can rename the bad file before running SQL*Loader, or specify the name of the bad file using the BADFILE clause followed by a filename. If you do not specify a name for the bad file, the name defaults to the name of the datafile with an extension or file type of .bad
    Specifying the Bad File
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28319/ldr_control_file.htm#i1005085
    Regards,
    Hussein

  • Can't rename MP4 files

    I can't rename MP4 files. Warnings says that I don't have permission. I have no problem changing any of my other  files that I want to rename.

    Thanks but I've tried all of the common methods of renaming a locked  file. Read/write permission doesn't unlock the file.  This is happening only a particular set of mp 4 files that I down loaded from my road warrior dash cam.
    I' ll have to keep searching for solution.  Thanks again.

  • Can't rename audio clips using letters - only numbers

    Hi There,
    ALl of a sudden I can't rename audio files in the "Audio" tab - it only accepts numbers no letters.
    Anyone else seen this?
    Am running Motion 4.0.3 on 10.6.7
    Any help would be much appreciated.
    Cherrs
    Ben

    Um, buddy, you're typing in a time code field.  You can only "reaname" in the Browser window.

  • Can't RENAME a file like Windows can?

    Real easy. I just need to rename a file from this:
    A2Capital.jpg
    to this:
    a2capital.jpg
    I do this in Windows and of course every OS I have used since the 1990s at least. Why can't this be done in OS X 10.4.9?
    I am on a network drive of a Windows Server, if that makes a difference. The error I always get is
    The name a2capital with extension ".jpg" is already taken. Please choose a different name.
    Oh, come on. This is an easy one, right?
    It happens whether I click the filename or if I Show Info.
    Mac Pro Quad 3.0 Mac OS X (10.4.9) I usually run Windows XP

    OS X's filesystem, HFS+, is case-preserving, meaning
    it stores the upper and lowercase characters of
    file/folder names, however it's not case-sensitive
    (unless you specify it as such when formatting the
    disk in Disk Utility). In a case-preserving
    filesystem, MyFile, mYfILE, myfile, and MYFILE all
    reference the same file. There is no need to be rude
    to Kappy, he was just trying to help. Here's some
    reading if you want to learn more:
    http://en.wikipedia.org/wiki/HFS_Plus
    http://en.wikipedia.org/wiki/Comparisonof_filesystem
    s#fn_35
    http://en.wikipedia.org/wiki/Case-preserving
    Note: HFSX in 10.3 added the ability to format a disk
    as Case-Sensitive. If you didn't reformat your disk
    when you got your Mac, it's Case-Preserving, not
    Case-Sensitive.
    I see what you mean by case sensitive. I think Macs and Windows are similar in this regard. All that means is that if I type in a command to run, or I type a filename to launch, the OS is forgiving if I say "BLaH.JpG" for a file that is really "blah.JPG" -- if it's on the hard drive like that already.
    You bet. But in both Mac and Windows it seems, I can rename the file to whatever mixed case I want and get no errors.
    I only have this problem on the network drive,
    which like I said is a Windows 2003 Server share.
    Because your question is in the context of renaming a
    file on a remote Windows share, then all the talk of
    whether HFS is case-sensitive or not doesn't matter.
    I'm assuming the share you're connected to when
    trying to do this rename is NTFS? Macs use Samba to
    connect to Windows shares. I've never tried to do
    what you're doing through a samba share. It could be
    Samba, or it could be how you have your share set up.
    It does look like a Samba idiosyncrasy. I have used Samba before in FreeBSD (a relative to Darwin/OS X) but I would have no idea if that was the case there.
    Samba has traditionally had some oddities, bugs, and problems due to the nature of open-sourcing a Windows custom secret network system. But Macs do claim to be interoperable with other networks and systems. This can't be unusual. Lots of people need to connect to a Windows share.
    Ha, to be honest, I don't think I would even try to setup a NFS share on the Windows server, and there aren't any UNIX servers at this location.
    Who heads up the Samba stuff for Mac OS?

  • Can't rename important file!

    Hi everybody
    well, I have quite an extraordinary situation here.
    Today morning I created an iStopMotion file (.mov) and renamed it, to my misfortune, with a VERY long name. The file's only copy is on my external drive (unfortunately FAT 32). If I now want to select the file, it simply just disappears (and only reappears if I restart the Finder). Hence, I can not rename it and therefor use it. It's a very important school file and I can not reproduce the file, I HAVE to rename it and be able to use it/convert it. How can I do that without losing the file or anything similar to that? I don't mind if the solution is very long, as long as it works I'm fine with it.
    Please help me!
    Thank you in advance.

    Can you open the file using the application's menu open command, then save it with a different name?
    Open the application with which you created the file. In the application menu go to File > Open and try opening the file. Then save it with a different name.
    You can also try the move (mv) command in Terminal:
    Open Terminal in your applications > utilities folder.
    Type in mv with a space after it. Do not press return yet.
    Drag the problem file to the Terminal window. This should result in the file with the directory path being entered in the window after the mv+space. Do not press return yet.
    Enter another space. Now type a new name for the file. In order to make things easy we are going to have the file go to your Home folder on your main drive.
    Now press return. This should move the file from the old place to the new place with a new name.
    If you do not want to risk erasing the first file while creating the second in case something goes wrong, use the copy "cp" command instead of the move "mv".

  • [Solved]Can I rename a file just by knowing its inode

    Hi!
    I have some files/directories with very weired characters in the filename.
    So, I was unable to rename them to something that is accessible by its filename.
    However, I can see their inode.
    Is there anyway that I can rename a file just by using its inode?
    thx
    Last edited by phabulosa (2008-03-18 23:11:30)

    Allan wrote:You can try using "find" to get the name of the file with that inode and then pipe that to "mv"
    I need to do this on a embedded busybox environment, so the 'find' utility does not has a feature of -inode.
    However, I achieved my goal by doing the following:
    1. Figure out the inode of a file/directory by
    ls -i
    2. Use a variable to save the filename which cannot by typed in due to weired characters
    xyz=`ls -i|grep 705|sed 's/48840705 //'`
    3. Rename by
    mv "$xyz" filename_I_want

  • How can I rename a file programmatically?

    I want to make a VI that rename a file, how can I do?

    Hello,
    A third method is to use "System Exec" vi and use the ubiquitos Rename Command.
    An Example is attached It needs a file temp.txt in C:\
    This is true renaming unlike other methods of copying and deleting.
    Good Luck
    Mache
    Good Luck!
    Mache
    Attachments:
    rename.vi ‏21 KB

  • How can I rename multiple files simultaneously

    I'm new to Macs and I'm looking for a way to rename multiple files simultaneously. These are photos from my SD card that I wish to give the same name but increment the name by 1 at the end of the filename.

    A Better Finder Rename is perfect for this.   I use it all the time to rename image files.
    There is also a companion app called A Better Finder Attributes that is also useful for image files.

  • Can not rename created file via UTL_FILE package

    Hi,
    I am wondering why I am not able to rename file after the procedure has created it?
    I am closing the file with UTL_FILE.FCLOSE (v_file);
    but it seems that oracle still keep it open.
    Any suggestions?
    Thanks
    BEGIN
    SELECT TO_CHAR (SYSDATE, 'YYYYMMDD')
    INTO v_sysdate4filename
    FROM DUAL;
    v_filename :=
    ('MyFileName_' || v_sysdate4filename || '.txt'
    v_file := UTL_FILE.FOPEN ('MY_DIR', v_filename, 'w');
    FOR v_current_row IN my_c
    LOOP
    UTL_FILE.PUT_LINE (v_file,
    v_current_row.record_type
    || v_current_row.operation_type
    || v_current_row.child_id
    || v_current_row.parent_id
    || v_current_row.start_date
    || v_current_row.end_date
    || v_current_row.process_field
    END LOOP;
    UTL_FILE.FCLOSE (v_file);
    END ;

    (I have administrator rights) Again, If you are not able to rename the file, what the error message is returned by the OS.
    Did you try to disconnect your Oracle session and then try?

  • How can I rename multiple files without Automator?

    Is there a way to rename a large number of files i.e. "file, file(2) file(3)" without using Automator? In Windows you can just right-click and rename any number of selected files.

    Oh, I heartily agree. I bought it back at version 1.0, but not everyone around here is willing to spend money. The one I suggested that's freeware is a pretty good tool especially for casual sorts of needs. You may want to take a look at it. Not that it replaces ABFR.

  • How can I rename many files at the same time?

    Hello!
    I have a bunch of PDF files (2 thousand at least) that I need to transfer to another Mac but since it's running OS 9.2 it won't accept the files because the names are too long, therefore, I need a quick way to change all such files into a shorter name but maintaining some of the serial numbers each file name has (i.e., not changing all to the same name but just taking off the first or last 5 characters for example), is there a way to do this sort of thing with OS 10.3.9 or 10.5.2?
    Best!
    Danny

    Look at this shareware. http://www.jonn8.com/ntf/ It's a batch renaming app, but I'm not sure it will do exactly what you want. However, it does have a 7 day free trial.
    If you do a Google serach using +batch file rename mac+ you can review a lot more apps.
     Cheers, Tom

  • Can you rename pdf files in ibooks?

    I download many PDF files onto my iPad to read using iBooks.  But the PDF files are stored on the iPad with non-meaningful names (like QL-BHZfG9dl).  Is there any way to rename these things so that I know (without opening them) what the files are??

    wozwoz wrote:
    If Apple want to have
    You can tell them your views on that via
    http://www.apple.com/feedback

  • Can I rename a file in iPhoto '08?

    I have a few pictures that have to be specified as to what the picture is of and I do not know how to rename the actual file. Can this even be done? Please help.

    Welcome to the Apple Discussions. You may edit the title in iPhoto to what you want the new file name to be and then export that file via the File->Export->File Export menu with the option selected to use the Title as the new file name.
    Click to view full size

  • How can I rename RAW files on my iPad?

    I am trying to find some way where I can rename, caption and keyword my photos on my iPad so that when I load them into Aperture those things go along with the photo.  I know that there are many ways to do this with conversion to jpeg or shooting RAW+jpeg but I do not want to do any of those.  I just shoot RAW, I don't bother with jpeg files at all.  I don't need to edit the photos in any way, I just want to add some metadata.
    I have Aperture and iPhoto on my iMac and I also have iPhoto on my iPad.

    Check out the Photo Manager Pro app.
     Cheers, Tom

Maybe you are looking for

  • Unique Index vs. Unique Constraint

    Hi All, I'm studying for the Oracle SQL Expert Certification. At one point in the book, while talking about indices, the author says that a unique index is not the same a unique constraint. However, he doesn't explain why they're two different things

  • Port Forwarding (for IP Camera)

    I have so far been unsuccessful in in setting up my new ip camera for remote monitoring. I have followed all instructions within the "bt homehub" domain for port forwarding in application sharing but when I check that the port (80) is open (using pfp

  • Your Client Does not Support Opening this list with Windows Explorer on Windows Server 2012 R2

    I am trying to open a document library in Internet Explorer 11 on a Windows 2012 R2 server and I am receiving Your Client Does not Support Opening this list with Windows Explorer

  • Annoying things in Acrobat 8 and 9

    Dear Acrobat Programmers, I don't know where i have to send it, so i post it here. I thought that i candle handle with all annoying things in Acrobat 8 (9 as well, all newest upgrades), but - no more. I have sometimes a lot of work and i'm going craz

  • How can I create this style? Rave Motion graphics etc. See link

    I'm fairly new to AE but here is the sort of thing I'm wanting to make Bobmo - "When I Look" ft. Shaun J. Wright - YouTube. Particularly the face at 0:28 and the background at 2:53. If anyone could point me in the direction of where I can learn this