The parameter type of a generic class/method must be declared at some point. For a generic class, you declare it in the class definition:
class X<T> {}
On the other hand, for a generic method within a class that is not generic, you have to declare it in the method declaration itself:
class NotGeneric{
public <T> X<T> genericMethod(String s, Class<T> cls){}
}
Finally, your error is probably due to a different issue, e.g., you might have jar files for javax.persistence
1.x or both 1.x and 2.0 at the same time in your classpath. The overloaded method was added in 2.0.