title: Java Spring 3 MVC Controllers explicitly load Services
body: <p>I'm working through some of Spring 3 annotation driven controllers and services and had a question on how this could be possible?</p>
  
  <ol>
  <li><p>I have in my <code>servlet-context.xml</code> file the paths for the following items to be loaded:</p>
  
  <p><code>&lt;context:component-scan base-package="com.project.controller, com.project.service"/&gt;</code></p></li>
  </ol>
  
  <p>Under a controller I have this in the init class, and the init is tagged as:</p>
  
  <pre><code>@PostConstruct
  public void init() {
      ApplicationContext context = new GenericApplicationContext();
      bizServices = (BizServices) context.getBean("bizServices");
  }
  </code></pre>
  
  <p>In my Services I have a bean for services tagged as:</p>
  
  <pre><code>@Service("bizServices")
  public class BizServicesImpl implements BizServices { ... }
  </code></pre>
  
  <p>I get the exception as:</p>
  
  <pre><code>SEVERE: Allocate exception for servlet Spring MVC Dispatcher Servlet
  org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named     'bizServices' is defined
  </code></pre>
  
  <p>This tells me either I am using the wrong application context service or the bean cannot be found. Can I locate and load this Service class explicitly in the PostConstruct without Autowire? What if I made my services classes loaded from a factory, can I designate what the factory class is, and would that be a bean config entry in the xml?</p>
  
  <p>Thanks again...</p>