java.io.FileNotFoundException: /home/user/image.jpg (Too many open files)

JIRA | Chris Kaempfe | 6 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    [JAVA-345] FileNotFoundException - too many open files - MongoDB

    mongodb.org | 2 years ago
    java.io.FileNotFoundException: /home/user/image.jpg (Too many open files)
  2. 0

    I'm getting the following error: <<< java.io.FileNotFoundException: /home/user/image.jpg (Too many open files) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:106) at com.mongodb.gridfs.GridFS.createFile(GridFS.java:239) <<< I'm migrating a Oracle DB to MongoDB. For the work I'm using several threads which reads Orcale and put the information to MongoDB. Therefor im crawling a filesystem for different files, which need to be inserted in MongoDB. My Code - within the thread - where I'm receiving the exception: File file = new File(filePath); GridFSInputFile inputFile = null; try { if(!file.exists()) { throw new FileNotFoundException("File: " + filePath + " does not exist."); } inputFile = grid.createFile(file); inputFile.put("media", "file"); inputFile.save(); } catch (IOException e) { log.error("MedienDBWorker addFile() - ID: " + workID + " ******* ", e); } Is seams that GridFSInputFile is creating an InputStream and after saving the file, the InputStream isn't closed nor is there a method to close the stream. How should this be handled? My workaround is: File file = new File(filePath); GridFSInputFile inputFile = null; try { if(!file.exists()) { throw new FileNotFoundException("File: " + filePath + " does not exist."); } final InputStream is = new FileInputStream(file); try { inputFile = grid.createFile(is,file.getName()); inputFile.put("media", "file"); inputFile.save(); } finally { is.close(); } } catch (IOException e) { log.error("MedienDBWorker addFile() - ID: " + workID + " ******* ", e); }

    JIRA | 6 years ago | Chris Kaempfe
    java.io.FileNotFoundException: /home/user/image.jpg (Too many open files)
  3. 0

    I'm getting the following error: <<< java.io.FileNotFoundException: /home/user/image.jpg (Too many open files) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:106) at com.mongodb.gridfs.GridFS.createFile(GridFS.java:239) <<< I'm migrating a Oracle DB to MongoDB. For the work I'm using several threads which reads Orcale and put the information to MongoDB. Therefor im crawling a filesystem for different files, which need to be inserted in MongoDB. My Code - within the thread - where I'm receiving the exception: File file = new File(filePath); GridFSInputFile inputFile = null; try { if(!file.exists()) { throw new FileNotFoundException("File: " + filePath + " does not exist."); } inputFile = grid.createFile(file); inputFile.put("media", "file"); inputFile.save(); } catch (IOException e) { log.error("MedienDBWorker addFile() - ID: " + workID + " ******* ", e); } Is seams that GridFSInputFile is creating an InputStream and after saving the file, the InputStream isn't closed nor is there a method to close the stream. How should this be handled? My workaround is: File file = new File(filePath); GridFSInputFile inputFile = null; try { if(!file.exists()) { throw new FileNotFoundException("File: " + filePath + " does not exist."); } final InputStream is = new FileInputStream(file); try { inputFile = grid.createFile(is,file.getName()); inputFile.put("media", "file"); inputFile.save(); } finally { is.close(); } } catch (IOException e) { log.error("MedienDBWorker addFile() - ID: " + workID + " ******* ", e); }

    JIRA | 6 years ago | Chris Kaempfe
    java.io.FileNotFoundException: /home/user/image.jpg (Too many open files)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    how to get the full file path from fileupload in java servlet from HTML

    Stack Overflow | 1 year ago | amit kaushik
    java.io.FileNotFoundException: fromJSON.csv (The system cannot find the file specified)
  6. 0

    How to insert image in mongodb and to retrieve image in java using netbeans

    Stack Overflow | 4 months ago | bharani m
    java.io.FileNotFoundException: C:\Users\Extreme\Pictures\image2.jpg (The system cannot find the file specified)

  1. rp 1 times, last 2 weeks ago
  2. Adrien 6 times, last 2 weeks ago
  3. gamebusterz 8 times, last 3 weeks ago
  4. michallos 1 times, last 1 month ago
  5. tyson925 4 times, last 1 month ago
52 more registered users
43 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.io.FileNotFoundException

    /home/user/image.jpg (Too many open files)

    at java.io.FileInputStream.open()
  2. Java RT
    FileInputStream.<init>
    1. java.io.FileInputStream.open(Native Method)
    2. java.io.FileInputStream.<init>(FileInputStream.java:106)
    2 frames
  3. MongoDB Java Driver
    GridFS.createFile
    1. com.mongodb.gridfs.GridFS.createFile(GridFS.java:239)
    1 frame