I am using spring data mongodb and want to use Journaled write concern.
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="mongo"/>
<constructor-arg name="databaseName" value="mytestdb" />
<!-- write concern is set to w=1, j=true -->
<property name="writeConcern" value="WriteConcern.JOURNAL_SAFE"/>
</bean>
Exception in thread "main" org.springframework.data.mongodb.UncategorizedMongoDbException: { "serverUsed" : "
barium17.nyc:27017" , "ok" : 0 , "code" : 2 , "errmsg" : "cannot use non-majority 'w' mode WriteConcern.JOURNAL_SAFE when a host is not a member of a replica set"}; nested exception is com.mongodb.CommandFailureException: { "serverUsed" : "
barium17.nyc:27017" , "ok" : 0 , "code" : 2 , "errmsg" : "cannot use non-majority 'w' mode WriteConcern.JOURNAL_SAFE when a host is not a member of a replica set"}
at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:78)
at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:1800)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:404)
at org.springframework.data.mongodb.core.MongoTemplate.insertDBObject(MongoTemplate.java:888)
at org.springframework.data.mongodb.core.MongoTemplate.doInsert(MongoTemplate.java:708)
at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:663)
at org.springframework.data.mongodb.core.MongoTemplate.insert(MongoTemplate.java:654)
at springmongo.dao.impl.EmployeeDAOImpl.insert(EmployeeDAOImpl.java:43)
at springmongo.SimpleTestdataInsert.insertEmployee(SimpleTestdataInsert.java:32)
at springmongo.SimpleTestdataInsert.main(SimpleTestdataInsert.java:59)
Please explain what i am doing wrong and is there anything i am misunderstanding about journaling enabled on mongod server and j=true flag on client side.