Friday, February 17, 2012

Spring and null ExternalContexts

After brief consternation of getting null values for Spring's ExternalContextHolder.getExternalContext() and RequestContextHolder.getRequestContext().getExternalContext() I realized that I was calling this code outside of Spring entirely!

From double-checking the docs I guess it seems that this is considered a "common sense" feature and isn't mentioned.

My only solace in the dreaded NullPointerException is that even the inventor doesn't like them.