A Prince Edward Island provincial court judge is questioning why the legal and healthcare systems were unable to find shelter for a homeless man on a bitterly cold New Year’s Eve.

Barry Joseph Flynn is charged with two counts of arson related to a pair of fires set just before Halloween. After his arrest he was sent for a psychiatric assessment to the East Coast Forensic Hospital in Dartmouth, N.S.

The 58-year-old man was returned to the Island on New Year’s Eve, but was refused a spot at the Hillsborough Hospital and Special Care Centre, a psychiatric facility in Charlottetown, because there was no bed for him.

So Judge Nancy Orr took the unusual step of ordering Flynn be sent to jail, locked up for his own protection.

In court on Friday she apologized to Flynn for having to do so.

"I am sorry, sir, for the time you spent in jail, but I didn't want you out on the street in severe cold," the judge told the man.

The judge said the situation resulted from major miscommunication between government agencies.

Crown prosecutor Cindy Wedge told court there is a capacity issue at Hillsborough hospital and at least two other patients had been waiting for beds at the same time as Flynn.

A bed is now available for Flynn at the hospital, and Wedge told the court correctional services has filed an incident report.

She said the departments of health and community services are looking into the problem.

Flynn thanked the judge for sending him to jail New Year’s Eve. He has not yet entered a plea to the charges and is scheduled to return to court on Jan. 21.