this piece of code is too small to know for sure the problem, but my guess is that you are executing it from inside a function, right? if so, the texture is deleted when the function ends, and the sprite loses reference to it.
you need to keep the texture alive. maybe show a bit more of this class code can help