Look at the line throwing the NPE. You are dereferencing something that is null on that line. What is it? You can use a debugger or some print statements to figure it out.