Stability criterion for multicomponent solitary waves