Not the best sollution, but I once found the problem by deleting a block every time in the template until the error did go away (do not forget to make a copy first of the template). Then you can focus on the block that is giving the problem.
Document templates are a bit of an orphan in Mendix. They deserve some more attentions of the developers.....
Regards,
Ronald