How can I make WebApplicationContext access beans in ApplicationContext?
<p>This is how I try to bootstrap Spring in my Java Web Application:</p>

<pre><code>public class SpringBootstrap implements WebApplicationInitializer {
    public void onStartup(ServletContext servletContext) throws ServletException {
        final AnnotationConfigApplicationContext rootContext = new AnnotationConfigApplicationContext();
        rootContext.register(RootContextConfiguration.class);

        final AnnotationConfigWebApplicationContext webContext = new AnnotationConfigWebApplicationContext();
        webContext.register(WebContextConfiguration.class);
        webContext.setParent(rootContext);

        final DispatcherServlet dispatcherServlet = new DispatcherServlet(webContext);
        final ServletRegistration.Dynamic dispatcher = servletContext.addServlet("springDispatcher", dispatcherServlet);
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");

        final ContextLoaderListener contextLoadListener = new ContextLoaderListener(webContext);
        servletContext.addListener(contextLoadListener);
    }
}
</code></pre>

<p>And RootContextConfiguration and WebContextConfiguration classes are as follows:</p>

<pre><code>@Configuration
@ComponentScan(basePackages = "biz.tugay.janeleven.root")
public class RootContextConfiguration {
}

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "biz.tugay.janeleven.web")
public class WebContextConfiguration {
    @Bean
    public ViewResolver viewResolver() {
        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
        return resolver;
    }
}
</code></pre>

<p>When I try deploying the application to Tomcat and start I will get:</p>

<blockquote>
  <p>Caused by:
  org.springframework.beans.factory.NoSuchBeanDefinitionException: No
  qualifying bean of type
  [biz.tugay.janeleven.root.service.AppUserService] found for
  dependency: expected at least 1 bean which qualifies as autowire
  candidate for this dependency. Dependency annotations:
  {@org.springframework.beans.factory.annotation.Autowired(required=true)}</p>
</blockquote>

<p>I am also including the HelloServlet and AppUserService classes here, with their package information:</p>

<p>package biz.tugay.janeleven.root.service;</p>

<pre><code>@Service
public class AppUserService {

    public AppUser addAppUser(String name) {
        final AppUser appUser = new AppUser(name);
        AppUserDB.addUser(appUser);
        return appUser;
    }

    public Collection&lt;AppUser&gt; getAllAppUsers() {
        return AppUserDB.getAll();
    }
}

package biz.tugay.janeleven.web;

@Controller
@RequestMapping(value = "/")
public class HelloWorldServlet {

    @Autowired
    private AppUserService appUserService;

    @RequestMapping(value = "", method = RequestMethod.GET)
    public String helloWorld(Model model) {
        final Collection&lt;AppUser&gt; appUserList = appUserService.getAllAppUsers();
        model.addAttribute("appUserList", appUserList);
        return "hello.jsp";
    }

    @RequestMapping(value = "", method = RequestMethod.POST)
    public String addApplicationUser(@RequestParam("username") String username) {
        appUserService.addAppUser(username);
        return "redirect:/";
    }

}
</code></pre>

<p>My expectation is that, WebContextConfiguration should be able to find beans that are managed by RootContextConfiguration since I am calling:</p>

<pre><code>webContext.setParent(rootContext);
</code></pre>

<p>during the bootstrap process. But obviously I am missing something.</p>