Find the line the exception is thrown, then backtrack to find how it can be null. Since you have not posted the stack trace, and this code is not an SSCCE, you don't make it easy for anyone to help...