MongoTimeoutException

506 views
Skip to first unread message

Michael Mogley

unread,
Feb 23, 2015, 6:01:01 PM2/23/15
to axonfr...@googlegroups.com
I'm getting a MongoTimeoutException when bootstrapping the event store. The weird thing is I can connect to the instance fine both from the command line and when executing a simple MongoClient test.  All of this is running on the same machine (meaning the MongoDB instance and Axon).  Here is the stack:

Caused by: com.mongodb.MongoTimeoutException: Timed out after 10000 ms while waiting to connect. Client view of cluster state is {type=Unknown, servers=[{address=27017:27017, type=Unknown, state=Connecting, exception={com.mongodb.MongoException$Network: Exception opening the socket}, caused by {java.net.ConnectException: No route to host}}]
    at com.mongodb.BaseCluster.getDescription(BaseCluster.java:128)
    at com.mongodb.DBTCPConnector.getClusterDescription(DBTCPConnector.java:394)
    at com.mongodb.DBTCPConnector.getType(DBTCPConnector.java:571)
    at com.mongodb.DBTCPConnector.createServerSelector(DBTCPConnector.java:554)
    at com.mongodb.DBTCPConnector.access$100(DBTCPConnector.java:40)
    at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:448)
    at com.mongodb.DBTCPConnector.getPrimaryPort(DBTCPConnector.java:407)
    at com.mongodb.DBCollectionImpl.createIndex(DBCollectionImpl.java:378)
    at com.mongodb.DBCollection.createIndex(DBCollection.java:597)
    at com.mongodb.DBCollection.ensureIndex(DBCollection.java:726)
    at com.mongodb.DBCollection.ensureIndex(DBCollection.java:700)
    at org.axonframework.eventstore.mongo.DocumentPerCommitStorageStrategy.ensureIndexes(DocumentPerCommitStorageStrategy.java:112)
    at org.axonframework.eventstore.mongo.MongoEventStore.ensureIndexes(MongoEventStore.java:122)

Anyone run into this or know what may be going on?

Michael

Michael Mogley

unread,
Feb 23, 2015, 7:01:51 PM2/23/15
to axonfr...@googlegroups.com
Solved. For anyone interested, the problem was in how I was wiring up the Mongo object in my Spring XML.  I had this:

  <bean id="mongoDb" class="com.mongodb.Mongo">
    <constructor-arg><value>${mongodb.host}</value></constructor-arg>
    <constructor-arg><value>${mongodb.port}</value></constructor-arg>
  </bean> 

Because I wasn't specifying the type of the constructor arguments, the wrong Mongo constructor was being invoked. This fixed it:

  <bean id="mongoDb" class="com.mongodb.Mongo">
    <constructor-arg type="java.lang.String"><value>${mongodb.host}</value></constructor-arg>
    <constructor-arg type="int"><value>${mongodb.port}</value></constructor-arg>
  </bean> 
Reply all
Reply to author
Forward
0 new messages