Call to a member function getResource() on null