java.io.IOException: There are no more files - (when copying a pdf to another location)

Viewed 2408

I inherited this code that contains a function that copies a .pdf file from one location to another, creating new folders (named by hash value) in the process, and saves the new path to a database that a BI tool later uses to access the file via an API.

After we moved the file server to a new host, and quadruple checked the permissions and path references, we receive this java.io.ioexception when copying the files to the new location in the code. The copy fails, the folders aren't created where applicable, and the files are not accessible through the API.

The log files show that the program correctly identifies the source file, and correctly builds the destination path.

Any ideas as to what is causing this IOexception? Haven't encountered this one before, and I can't seem to find a relatable thread anywhere on the internet.

Function:

import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;

public boolean pushFile(File file, String newFileName)
{
    File newFile = new File(SAN_LOCATION + "\\" + newFileName.subSequence(0, 2) + "\\" + newFileName);

    try
    {

        System.out.print("Copying " + file.getName() + " to: " + newFile.getAbsolutePath());
        FileUtils.copyFile(file, newFile);
        System.out.println(" - Good file transfer");

    } catch (IOException ex)
    {
        System.out.println(" - Bad file transfer");
        Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    }
    return true;
}

Log Snippet:

Copying ARC FERM 2019-06-18 07-35-58_AM0000006.pdf to: \\tf-fs-1\arcstor\fc\fc3533e07547850176b671730ddccfcc - Bad file transfer
java : Jun 18, 2019 11:01:27 AM datatosql.PushToSQL pushFile
At C:\arc\ch_agilent_hplc.ps1:2 char:1
+ java -jar ".\Agilent.jar" CH HPLC "$file" 2>&1 | Out-File C:\arc\Logs\Agilent\ch ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Jun 18, 2019 11...hToSQL pushFile:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

SEVERE: null
java.io.IOException: There are no more files
    at java.io.WinNTFileSystem.canonicalize0(Native Method)
    at java.io.WinNTFileSystem.canonicalize(Unknown Source)
    at java.io.File.getCanonicalPath(Unknown Source)
    at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1076)
    at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1040)
    at datatosql.PushToSQL.pushFile(PushToSQL.java:763)
    at datatosql.PushToSQL.push(PushToSQL.java:508)
    at agilent.Agilent.main(Agilent.java:503)
    enter code here
2 Answers

Googling "There are no more files" finds people who are having issues with security software, particularly ASUS Data Security Manager. So I suspect that the problem is not in your Java code. You can prove this by manually copying a file, something like this:

copy some.file "\\tf-fs-1\arcstor\fc\fc3533e07547850176b671730ddccfcc"

I got the path from your error message, but check it's correct! I think that you need the quotes around the path. My guess is that this won't work because it's being blocked by something on the remote machine.

I faced a similar problem. In my case, I was using FileUtils.copyFile(file, newFile) in a loop. After 258 successful copies, I would get that error. I altered my code to use Files.copy(sourcePath, destPath) instead, and the problem went away.

Related