Bug detected into com.fasterxml.jackson.databind.ser.impl.WritableObjectId#writeAsField gen.writeObjectId(String.valueOf(id)); shoud be if(id!=null)gen.writeObjectId(String.valueOf(id));