title: problem in Spring session scope bean with AOP
body: <p>I want to inject currentUser instance in HomeController class. so for every request, HomeController will have currentUser object.</p>
  
  <p>My configuration:</p>
  
  <pre><code>&lt;bean id="homeController" class="com.xxxxx.actions.HomeController"&gt;
      &lt;property name="serviceExecutor" ref="serviceExecutorApi"/&gt;
      &lt;property name="currentUser" ref="currentUser"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="userProviderFactoryBean" class="com.xxxxx.UserProvider"&gt;
      &lt;property name="userDao" ref="userDao"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="currentUser" factory-bean="userProviderFactoryBean" scope="session"&gt;
      &lt;aop:scoped-proxy/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>But I am getting following error.</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: Cannot create scoped proxy for bean 'scopedTarget.currentUser': Target type could not be determined at the time of proxy creation.
          at org.springframework.aop.scope.ScopedProxyFactoryBean.setBeanFactory(ScopedProxyFactoryBean.java:94)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1350)
          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
  </code></pre>
  
  <p>What is the problem? and Is there any better/simple alternative?</p>
  
  <p>Cheers.</p>