nullPointerException solved. New Exception is thrown. Why?