Backport: Fixed possible NPE when no explicit classloader was given to t...

...he classloader cache