What's probably happening is that the code you're calling is happening outside of a transaction.
You've posted the code above, so you can see that the NPE is probably happening because the ProcessInstanceImpl.kruntime field is null.
The kruntime field in the ProcessInstanceImpl is set to null as soon as the transaction is closed. This has to do with making sure that jBPM doesn't cache old copies of processinstances.
So, in this case, when you call
wpi.getNodeInstances()
the transaction has already ended (it ended within the ksession.getProcessInstance() method).
May I ask why you want a list of NodeInstances? There may be other ways to get the information that you're looking for. Also, at the moment that you're looking for the node instances, there shouldn't be any or otherwise you're betting on a race condition.