Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5848561
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:52:36+00:00 2026-05-22T12:52:36+00:00

I use library which download torrents. But today some error happened (log): Could not

  • 0

I use library which download torrents. But today some error happened (log):

Could not create temp files
java.io.IOException: Invalid argument
    at java.io.RandomAccessFile.setLength(Native Method)
    at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:261)
    at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
    at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.IOException: Invalid argument
    at java.io.RandomAccessFile.setLength(Native Method)
    at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:261)
    at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
    at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.IOException: Invalid argument
    at java.io.RandomAccessFile.setLength(Native Method)
    at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:261)
    at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
    at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.IOException: Invalid argument
    at java.io.RandomAccessFile.setLength(Native Method)
    at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:261)
    at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
    at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.FileNotFoundException: /root/TorrentStealer/downloads/MAME - Update ROMs (v0.141 to v0.141u2)/lah_l104.zip (Too many open files)
    at java.io.RandomAccessFile.open(Native Method)
    at java.io.RandomAccessFile.(RandomAccessFile.java:212)
    at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:260)
    at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
    at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.FileNotFoundException: /root/TorrentStealer/downloads/Degrassi.Junior.High.S01-S03.INTERNAL.DVDRip.XviD-FFNDVD/Degrassi.Junior.High.S01.INTERNAL.DVDRip.XviD-FFNDVDDegrassi.Junior.High.S01E10.INTERNAL.DVDRip.XviD-FFNDVDdegrassi.junior.high.s01e10.internal.dvdrip.xvid-ffndvd.r10 (Too many open files)
    at java.io.RandomAccessFile.open(Native Method)
    at java.io.RandomAccessFile.(RandomAccessFile.java:212)
    at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:260)
    at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
    at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Could not create temp files
java.io.FileNotFoundException: /root/TorrentStealer/downloads/MAME - Update ROMs (v0.141 to v0.141u2)/lah_l108.zip (Too many open files)
    at java.io.RandomAccessFile.open(Native Method)
    at java.io.RandomAccessFile.(RandomAccessFile.java:212)
    at jBittorrentAPI.DownloadManager.checkTempFiles(DownloadManager.java:260)
    at jBittorrentAPI.DownloadManager.(DownloadManager.java:108)
    at torrentstealer.DownloadTorrent.run(DownloadTorrent.java:65)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

And so on, log continues. I found that this file exists and here is a part of code where error happens:

    /**
     * Check the existence of the files specified in the torrent and if necessary,
     * create them
     *
     * @return int
     * @todo Should return an integer representing some error message...
     */
    public synchronized int checkTempFiles() {
        String saveas = Constants.SAVEPATH; // Should be configurable
        if (this.nbOfFiles > 1)
            saveas += this.torrent.saveAs + "/";
        else
        {
            this.torrent.saveAs = this.torrent.name.get(0).toString();
        }
        new File(saveas).mkdirs();
        for (int i = 0; i < this.nbOfFiles; i++) {
            File temp = new File(saveas + ((String) (this.torrent.name.get(i))));
            try {
                this.output_files[i] = new RandomAccessFile(temp, "rw");
                this.output_files[i].setLength((Integer)this.torrent.length.get(
                        i));
            } catch (IOException ioe) {
                System.err.println("Could not create temp files");
                ioe.printStackTrace();
            }
        }
        return 0;
    }

Which called here:

        // запуск закачки
        dm.startListening(49152, 65535);
        dm.startTrackerUpdate();

    while(true)
    {
        if(dm.isComplete())
        {
            break;
        }

        try
        {
            Thread.sleep(100);
        }
        catch(InterruptedException ex)
        {
            Logger.getLogger(DownloadTorrent.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    dm.stopTrackerUpdate();
    dm.closeTempFiles();</code></pre>

And upper code called here:

ex = Executors.newFixedThreadPool(3);

for(String torrentFile : torrentFiles)
{
ex.submit(new DownloadTorrent("/root/TorrentStealer/torrents/" + torrentFile));
}

// ожидание завершения потоков загрузки файлов торрентов
ex.shutdown();

try
{
ex.awaitTermination(30, TimeUnit.MINUTES);
}
catch(InterruptedException ex1)
{
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex1);
}

ex.shutdownNow();</code></pre>

Here is description of fixing «Too many open files»:
http://wiki.magnolia-cms.com/display/WIKI/Too+Many+Open+Files

I set up 999999 max files, that fixed error for some time, then set up 9999999 for testing, not really works, all the time error happens. There can't be 9999999 opened files at the one moment after running when the server has been rebooted!

So men I don't know what to do. Can you help me?

Here is count of opened files when exceptions happened:
T217:~# lsof | wc -l
Result is: 2708

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:52:37+00:00Added an answer on May 22, 2026 at 12:52 pm

    The stacktrace indicated error at java.io.RandomAccessFile.setLength() which accept a long data type. In your code you cast the result of this.torrent.length.get(i) to Integer.

    What does this.torrent.length.get(i) return?

    it could be some downsizing issue when you convert data from the return to Integer, probably returning negative number which caused RandomAccessFile.setLength() to error out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use this library (which looks very nice) but I'm having difficulty
I'm trying to use curses.h library for the first time, but no matter which
I use a 3rd party library which returns after a lot of computation a
I have a c-library which I use in gcc. The library has the extension
I wrote library which can add and update objects in salesforce. I use beatbox
I use FreeType in my Android applications as a static library which i compile
which library would you advise me to use? I don't know any of these
I have just started to use ServiceStack which is an amazing library. However, I
I want to use NSCalendarDate, which exists in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/ System/Library/Frameworks/Foundation.framework/Versions/C/Headers/NSCalendarDate.h but is not present
There is Java tool (it is called Mallet) http://mallet.cs.umass.edu/download.php which I want to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.