Change hostname verifier to use thread's classloader

Fixes #2779 where the class was not found because it was added inside an application classloader context.