A man who trespassed on Selena Gomez's property in Calabasas, Calif., is going to jail for 45 days. The singer/actress called police on Sunday night after she heard something strange outside her door.

A man then rang the front doorbell and asked her friend if the star was at home, but her friend insisted she wasn't and he left. Officials later found Che Cruz, 20, in her guest house.

Cruz was arrested and charged with burglary and trespassing. On Wednesday, he pleaded no contest to a misdemeanor charge of unauthorized entry of a dwelling house and was sentenced to serve time at Los Angeles County Jail.

Cruz was also given three years probation, banned from possessing weapons and was ordered to stay away from Gomez, according to the LA County District Attorney's Office.

Gomez has had problems with trespassers in the past. Juan Garcia was arrested outside her old house in Tarzana, Calif., in January and was sentenced to 120 days in Los Angeles County Jail for trespassing.

In 2011 she had to deal with a stalker, Thomas Brodnicki, 46. He had repeatedly talked about killing Gomez.