title: Spring Transactional annotation giving CGLIB error
body: <p>I am getting the following error when using the @Transactional annotation. Any ideas?</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myRepository' defined in file [myFile]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class myRepository]: 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
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:191)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:636)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
      at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
      at myRepository.main(myRepository.java:104)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  Caused by: org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class myRepository]: 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
      at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:217)
      at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:111)
      at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:477)
      at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
      at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:409)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1520)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
      ... 16 more
  Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
      at org.springframework.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:721)
      at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:499)
      at org.springframework.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
      at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
      at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
      at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
      at org.springframework.cglib.proxy.Enhancer.create(Enhancer.java:285)
      at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:205)
  </code></pre>
  
  <p>Code: </p>
  
  <pre><code>@Repository
  public class MyRepository {
  
      private MyDao myDao;
  
  
      @Autowired
      public MyRepository(MyDao myDao) {
          this.myDao = myDao
      }
  
      @Transactional
      public void save(Object obj) {
          if (obj.isNew())
              myDao.create(obj)
  
      }
  }
  </code></pre>
  
  <p>XML:</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
     xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-3.0.xsd
  http://www.springframework.org/schema/tx
  http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"&gt;
  
  &lt;!-- Enable Annotation based Declarative Transaction Management --&gt;
  &lt;tx:annotation-driven proxy-target-class="true"
                        transaction-manager="transactionManager" /&gt;
  
  &lt;!-- Creating TransactionManager Bean, since JDBC we are creating of type DataSourceTransactionManager --&gt;
  &lt;bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="dataSource"
        class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" &gt;
  
   // datasource settings
  &lt;/bean&gt;
  </code></pre>