title: How can i fix this java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
body: <p>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:</p>
  
  <pre><code>@Service
  public abstract class BaseClass&lt;T&gt; {
     private Type type = ((ParameterizedType)this.getClass().getGenericSuperclass()).getActualTypeArguments()[0]
  }
  
  @Service
  public class SubClass extends BaseClass&lt;MyType&gt; {
  
     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;
     }
  }
  </code></pre>
  
  <p>Now i get </p>
  
  <blockquote>
    <p>"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</p>
  </blockquote>
  
  <p>I define the Type in my SubClass. Why i must define the Type again in SubSubClass?</p>