Issue 5849 stackoverflow velocity serialize

fix for master-2.5