catch NoClassDefFoundError when scanning for model classes

(cherry picked from commit a58392ca52dd9b7b75657daaf0d5795a43247a3f)