Search code examples
javanullclasspathclassloader

getClass().getClassLoader().getResourceAsStream is throwing a NullPointerException


In Java How could getClass().getClassLoader() return null?

  • The jar the 'class' is located in is NOT located under common/lib.
  • The jar is NOT being boostrap-loaded.

The ClassLoader for all classes within the jar is null.


Solution

  • Are you using any endorsed standards? I believe this would cause the classes to be loaded by the bootstrap class loader even though you may not be explicitly using -Xbootclasspath.