title: Injection of autowired dependencies failed while using @Transactional
body: <p>I testing my DAO, but it didn't work. The following error occurs:</p>
  
  <pre><code>Tests in error: 
    testAccountOperations(com.tsekhan.rssreader.dao.HibernateControllerTest): Error creating bean with name 'com.tsekhan.rssreader.dao.HibernateControllerTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.tsekhan.rssreader.dao.HibernateController com.tsekhan.rssreader.dao.HibernateControllerTest.hibernateController; nested exception is java.lang.IllegalArgumentException: Can not set com.tsekhan.rssreader.dao.HibernateController field com.tsekhan.rssreader.dao.HibernateControllerTest.hibernateController to $Proxy25
  </code></pre>
  
  <p>My DAO:</p>
  
  <pre><code>@Service
  @Scope("singleton")
  public class HibernateController extends HibernateDaoSupport {
  
      @Autowired
      public SessionFactory sessionFactory;
  
      @Transactional
      public void addAcount(Account account) {
          sessionFactory.getCurrentSession().saveOrUpdate(account);
      }
  }
  </code></pre>
  
  <p>My test for this DAO:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration("classpath:/applicationContext.xml")
  public class HibernateControllerTest {
  
      @Autowired
      HibernateController hibernateController;
  
      private Set&lt;Channel&gt; getTestChannelList(String channelLink) {
          Channel testChannel = new Channel();
          testChannel.setSourceLink(channelLink);
          Set&lt;Channel&gt; testChannelList = new HashSet&lt;Channel&gt;();
          testChannelList.add(testChannel);
          return testChannelList;
      }
  
      private Account getTestAccount(String accountLogin, String channelLink) {
          Account testAccount = new Account();
          testAccount.setAccountLogin(accountLogin);
          testAccount.setChannelList(getTestChannelList(channelLink));
          return testAccount;
      }
  
      @Test
      public void testAccountOperations() {
          hibernateController
                  .addAcount(getTestAccount("test_login", "test_link"));
      }
  }
  </code></pre>
  
  <p>My <em>applicationContext.xml</em>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &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.1.xsd
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.1.xsd"
          default-autowire="byName"&gt;
  
      &lt;!-- Enabling spring-transaction annotations --&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
  
      &lt;!-- Enabling annotation-driven configurating --&gt;
      &lt;context:annotation-config /&gt;
  
      &lt;!-- Creation of transaction manager --&gt;
  
      &lt;bean id="transactionManager" scope="singleton" 
          class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory"/&gt;
      &lt;/bean&gt;
  
      &lt;bean id="sessionFactory" scope="singleton"
          class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
          &lt;property name="configLocation" value="classpath:/hibernate.cfg.xml"/&gt;
          &lt;property name="configurationClass"&gt;
              &lt;value&gt;org.hibernate.cfg.AnnotationConfiguration&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
      &lt;!--
      A Spring interceptor that takes care of Hibernate session lifecycle.
      --&gt;
      &lt;bean id="hibernateInterceptor" 
              class="org.springframework.orm.hibernate3.HibernateInterceptor"&gt;
          &lt;property name="sessionFactory"&gt;
              &lt;ref bean="sessionFactory"/&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean name="employeeDAO" scope="prototype" 
          class="com.tsekhan.rssreader.dao.HibernateController" /&gt;
  
      &lt;!-- Searching for hibernate POJO files in package com.tsekhan.rssreader.web --&gt;
      &lt;context:component-scan base-package="com.tsekhan.rssreader.web" /&gt;
      &lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /&gt;
      &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>I note, that if you comment @Transactional in DAO, bean is created correctly. What happens?</p>