Fixed NPE when getResourcePath() returns null

Sometimes getResourcePath() would return null which caused a NullPointerException