Is there something wrong with the way I’m accessing the static field ‘cache’ from the config loader class? FYI, CacheEngine is an interface that implements a cache client for memcached.
public class Test {
...
getCache(){
...
try{
cacheData = ConfigLoader.cache.get(key); // Accessing the static 'cache' memeber returns Null Pointer Exception
...
}
}
}
//ConfigLoader Class
public class ConfigLoader{
public static CacheEngine cache;
...
}
It’s bad design, but the way you access it, is correct. Your problem is, that
cacheisn’t initialized. You need to do so somewhere: