com.mongodb.MongoException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • If you pass in a list of servers, one must be master. If you just want to connect to a slave, do "new Mongo(new ServerAddress(ip))". On Tue, Sep 7, 2010 at 10:46 AM, Joseph Wang <josephykwang@yahoo.com> wrote: String[] servers = server_list.split(","); ArrayList<ServerAddress> addr = new ArrayList<ServerAddress>(); int serverCount = 0; for (int i = 0; i < servers.length; ++i) { String[] serverInfo = servers[i].split(":"); try { if (serverInfo.length == SERVER_INFORMATION_FIELD_SIZE) { System.out.println("MongoConnnection: add server " + serverInfo[SERVER_NAME_FIELD] + " at port " + serverInfo[SERVER_PORT_FIELD]); ServerAddress host = new ServerAddress( serverInfo[SERVER_NAME_FIELD], Integer.parseInt(serverInfo[SERVER_PORT_FIELD])); addr.add(host); serverCount++; } } catch (Exception ex) { } } if (serverCount > 0) { m = new Mongo(addr, opt); } From: Kristina Chodorow <kristina@10gen.com> To: mongodb-user@googlegroups.com Sent: Tue, September 7, 2010 7:16:19 AM Subject: Re: [mongodb-user] Java Driver Failed to Connect to Slaves What does your code look like? Are you calling "new Mongo(ip1, ip2)"? If you're connecting to a slave, you should just say "new Mongo(ip1)". On Tue, Sep 7, 2010 at 1:01 AM, Joseph Wang <josephykwang@yahoo.com> wrote: MongoConnnection: add server ip-10-160-86-4 at port 10000 MongoConnnection: add server ip-10-161-50-230 at port 10000 ... SEVERE: switched to: ip-10-160-86-4:10000 but isn't master Sep 7, 2010 12:58:04 AM com.mongodb.DBTCPConnector _pickInitial SEVERE: can't pick initial master, using random one com.mongodb.MongoException: can't find master at com.mongodb.DBTCPConnector._pickInitial(DBTCPConnector.java:422) at com.mongodb.Mongo.<init>(Mongo.java:177)
    via by Joseph Wang,
  • [mongodb-user] db error [not master]
    via by Zsombor,
    • com.mongodb.MongoException: can't find master at com.mongodb.DBTCPConnector._pickInitial(DBTCPConnector.java:422) at com.mongodb.Mongo.<init>(Mongo.java:177)
    No Bugmate found.