Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1343

Proof of concept failed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker - P1
    • Resolution: Works as Designed
    • Affects Version/s: 2.12.3
    • Fix Version/s: None
    • Component/s: GridFS
    • Labels:
      None
    • Environment:
      Mongodb in Linux, application on Windows 7

      Description

      Exception in thread "main" com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches AnyServerSelector{} after 10000 ms
          at com.mongodb.BaseCluster.getServer(BaseCluster.java:87)
          at com.mongodb.DBTCPConnector.getServer(DBTCPConnector.java:654)
          at com.mongodb.DBTCPConnector.access$300(DBTCPConnector.java:39)
          at com.mongodb.DBTCPConnector$MyPort.getConnection(DBTCPConnector.java:503)
          at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:451)
          at com.mongodb.DBTCPConnector.getPrimaryPort(DBTCPConnector.java:409)
          at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:182)
          at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:165)
          at com.mongodb.DBCollection.insert(DBCollection.java:161)
          at com.mongodb.DBCollection.insert(DBCollection.java:107)
          at com.mongodb.DBCollection.save(DBCollection.java:966)
          at com.mongodb.DBCollection.save(DBCollection.java:934)
          at com.mongodb.gridfs.GridFSInputFile._dumpBuffer(GridFSInputFile.java:281)
          at com.mongodb.gridfs.GridFSInputFile.saveChunks(GridFSInputFile.java:231)
          at com.mongodb.gridfs.GridFSInputFile.save(GridFSInputFile.java:177)
          at com.mongodb.gridfs.GridFSInputFile.save(GridFSInputFile.java:158)
          at es.db.mongodb.MongodbTest.main(MongodbTest.java:76)

      The code:

      public class MongodbTest {
           
           
          public static void main(String[] args) throws IOException {
       
       
              System.out.println("Entered mongotest");       
              MongoClient mongoClient = new MongoClient("192.168.1.214", 27017);
                 
              //http://api.mongodb.org/java/2.10.1/com/mongodb/MongoClient.html
              //A MongoDB client with internal connection pooling. For most applications,
              //you should have one MongoClient instance for the entire JVM.   
             
              DB db = mongoClient.getDB("test");
             
              DBCollection collection = db.getCollection("downloads_meta");
       
              String filePath = "C:\\axd\\dell_fig1.jpg";
              File file = new File(filePath);
       
              GridFS gridfs = new GridFS(db, "downloads");
              GridFSInputFile gfsFile = gridfs.createFile(file);
              gfsFile.setFilename("dell_fig1.jpg");
              gfsFile.save();  //It crashes here.
       
       
              BasicDBObject info = new BasicDBObject();
                      info.put("name", "Dell");
                      info.put("fileName", "dell_fig1.jpg");
                      info.put("rawName", "dell_fig1.jpg");
                      info.put("rawPath", "C:\\axd");
       
              collection.insert(info, WriteConcern.SAFE);
          }   
      }

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: