title: AnnotationConfigApplicationContext and parent context
body: <p>I'm facing an issue trying to define a context hierarchy using <code>AnnotationConfigApplicationContext</code>. </p>
  
  <p>The problem is when defining a module context inside <code>beanRefContext.xml</code> and setting the 'parent' property with another context (XML/Annotated based).  </p>
  
  <p>Example:</p>
  
  <p><strong>beanRefContext.xml in module A</strong></p>
  
  <pre>
  &lt;bean id="moduleA_ApplicationContext"  
        class="org.springframework.context.support.ClassPathXmlApplicationContext">
      &lt;property name="configLocations">
          &lt;list>
              &lt;value>classpath:db-context.xml&lt;/value>
          &lt;/list>
      &lt;/property>
  &lt;/bean>
  </pre>
  
  <p><em>db-context.xml</em></p>
  
  <pre>
  &lt;bean id="dataSource" 
        class="org.apache.commons.dbcp.BasicDataSource" 
        destroy-method="close"
        p:driverClassName="org.h2.Driver"
        p:url="jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=MySQL;TRACE_LEVEL_SYSTEM_OUT=2"/>
  
  &lt;!-- Hibernate Session Factory -->
  &lt;bean name="sessionFactory" 
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
          &lt;property name="dataSource" ref="dataSource"/>
          &lt;property name="useTransactionAwareDataSource" value="true"/>
          &lt;property name="packagesToScan">
              &lt;list>
                  &lt;value>com.example.model&lt;/value>
              &lt;/list>
          &lt;/property>
          &lt;property name="hibernateProperties">
          &lt;!-- hibernate props -->
          &lt;/property>
  &lt;/bean>
  
  </pre>
  
  <p><strong>beanRefContext.xml in module B</strong></p>
  
  <pre>
  &lt;bean id="moduleB_ApplicationContext" 
        class="org.springframework.context.annotation.AnnotationConfigApplicationContext" >
      &lt;property name="parent" ref="moduleA_ApplicationContext"/>
          &lt;constructor-arg>
              &lt;list>
                  &lt;value>com.example.dao&lt;/value>
              &lt;/list>
          &lt;/constructor-arg>
  &lt;/bean>
  </pre>
  
  <p><em>FooHibernateDao</em></p>
  
  <pre>
  class FooHibernateDao implements FooDao {
      @Autowired
      @Qualifier("sessionFactory")
      private SessionFactory sessionsFactory;
  
      // CRUD methods
  }
  </pre>
  
  <p>Module B application context fails to find bean defined in module A application context.<br>
  From looking at the code of <code>AnnotationConfigApplicationContext</code> it seems that the scanning process doesn't use the parent as a reference to resolve beans.</p>
  
  <p>Is there something I'm doing wrong or my attempt to create a hierarchy is impossible with annotation configuration?</p>