An elderly witness died on a toilet in a court in Kiel, northern Germany, and his body was not found for three days.
The man, 70, is thought to have died of a heart attack but staff assumed the cubicle had been locked for maintenance work and did not suspect the truth.
He had been due to attend a criminal trial involving fake car accidents on Monday 29 October, but it was halted when he failed to show up.
An official finally discovered his body last Thursday.
Beate Flatow, vice-president of the court, said that lessons had been learnt and security staff would in future check all "publicly accessible rooms, especially the toilets".
Why did nobody notice?
After the unnamed witness had failed to appear last Monday, the judge cancelled the main hearing.
Court officials tried in vain to reach the missing man by telephone that day and Tuesday, while Wednesday was a public holiday, Reformation Day.
A court sergeant noticed on Thursday that one of the cubicles in the public toilets was locked but there was no sound from within, Judge Myriam Wolf told local newspaper Kieler Nachrichten.
The sergeant thought this odd, especially as the cubicle had been locked on Monday too.
When he found it still locked some hours later, he looked under the door and discovered the dead man "in a sitting position" with a court document lying on the floor.
Ms Flatow suggested that previous problems with a burst pipe in the toilets might have been the reason cleaning staff did not find it suspicious that a cubicle had been locked, thinking it had been shut by the caretaker as a safety measure.