There can be many reasons. One for an NPE would be when the code is in one place a variable is still not initialized and when it is in another place, the variable has a valid value.

You have to...