Bishops, priests, and deacons are clerics. Canon 277 obliges clerics to observe perfect and perpetual continence and celibacy for the kingdom of heaven and that they "can adhere more easily to Christ with an undivided heart and can more freely dedicate themselves to the service of God and humankind."
Canon 1037 requires that unmarried candidates for the permanent diaconate and candidates for the priesthood must publicly assume before God and the Church the obligation of celibacy if they have not professed vows (including chastity) in a religious institute. Married men who are ordained to the permanent diaconate who become widowed may not remarry without a dispensation.
Of course, all Christians are called to chastity. A Concise Dictionary of Theology (Paulist) defines chastity as: "that virtue which enables human beings to integrate sexuality within their whole personality according to their vocation in life: for the celibate, through complete abstention, for the married, through fidelity and for single persons, through self-control."
The violation of chastity by anyone is a sin if all the conditions of sin are present.