NullPointerExceptions are most of the time easy to track down and fix. Look at the stack trace that you get from the exception. It tells you exactly in which source file, and which line of code, the exception happens. Go to that spot in your source code and find out what could be null there that is not supposed to be null.
The most common causes of a NullPointerException are trying to call a method on a variable that is null or trying to access a member variable while the variable that refers to the object is null.
The outline of your code that you posted doesn't give enough information to help you with this problem.