If the restraining order is against YOU, then you could be in trouble. If it is against HIM, then probably not. Read the wording of the restraining order to determine whether you are in violation.
If the restraining order is against you, then you can be in trouble for violating. If you get charged you do possibly face jail time in Massachusetts - depending on your record.
In the future if you need to have him served in hand you can have it done via a constable for a reasonable fee. Also if you need to communicate with him, you can do so through an attorney...anyone else could be considered an agent and could get you in trouble.
If you are the defendant on the restraining order ("RO"), i.e. your ex has the RO on you, then your going to his apartment (regardless of the reason) is a violation of that RO. Even if he invites you over and you go over, that is a violation of the RO.
A violation of a 209A order is a crime that is punishable by a fine of not more than five thousand dollars, or by imprisonment for not more than two and one-half years in a house of correction, or by both such fine and imprisonment. G.L. ch. 209A, s.7 also authorizes a judge to order a person found in violation of an RO to enter and complete a certified batterer's program.
If your ex's roommates report this incident to the police, you will likely be charged with a violation of the restraining order. Note also that arguing that the RO was not validly issued (i.e. because he lied to get it or a similar argument) is not a defense at a trial for violating the order.
If you need to communicate with your ex, hire a lawyer and have that lawyer contact your ex. This will avoid further violations of the RO.