On the existence of compositional barrier certificates