title: Problem instantiating generic class bean in Spring
body: <p>I'm trying to instantiate a generic class in Spring, but I get following exception:</p>
  
  <blockquote>
    <p>Initialization of bean failed; nested exception is 
    org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class football.dao.jpa.GenericJpaDAO]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given:</p>
  </blockquote>
  
  <p>This is the XML configuration for Spring container:</p>
  
  <pre><code>&lt;bean id="clubDAO" class="football.dao.jpa.GenericJpaDAO"&gt;
      &lt;constructor-arg type="EntityManagerFactory" ref="entityManagerFactory"/&gt;
      &lt;constructor-arg type="Class" value="football.model.entities.ClubEntity"/&gt;
      &lt;constructor-arg type="String" value="ClubEntity"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>This is the generic class:</p>
  
  <pre><code>public class GenericJpaDAO &lt;T extends HavingID&gt; {
  
    private EntityManager em;
    private Class entityClass;
    private String entityName;
  
    public GenericJpaDAO( Class entityClass, String entityName,
          EntityManagerFactory emFactory ) {
      this.entityClass = entityClass;
      this.entityName = entityName;
      em = emFactory.createEntityManager();
    }
  
    @Transactional
    public void create( T entity ) {
        em.persist( entity );
    }
    // more methods
  
  }
  </code></pre>
  
  <p>I'm not really sure what could be causing this. I would appreciate any ideas.</p>