If you want to avoid the compiler warning you can use one of the unmarshal methods that takes a Class
parameter.
JAXBElement<User> jaxbElement = unmarshaller.unmarshal(sr, User.class);
Note
Your code should run perfectly fine as you have it in your question.