This is the most obvious I have seen must be true beginner. Anyway when you get NullPointerException than look at the line and see if any object on which you are calling method, variable or doing synchronization is null , that would be the reason.