I have three Classes. A Base Class, a Sub Class who extends from the Base Class and a Sub Class who extends from the First Sub Class like This:
@Service
public abstract class BaseClass<T> {
private Type type = ((ParameterizedType)this.getClass().getGenericSuperclass()).getActualTypeArguments()[0]
}
@Service
public class SubClass extends BaseClass<MyType> {
private static final String URL = "/test"
public MyType mainMethodOfThisClass(...) {
...
}
protected String getUrl() {
return URL;
}
}
@Service
public class SubSubClass extends SubClass{
private static final String URL = "/test/test"
@Override
protected String getUrl() {
return URL;
}
}
Now i get
"Error creating bean with name 'SubSubClass' Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
I define the Type in my SubClass. Why i must define the Type again in SubSubClass?