title: Spring MVC: Controller does not run in an ApplicationContext
body: <p>I am trying to implement a WebApp using Spring MVC Framework. So far, HelloWorld wasn't a problem. Now I wanted to read in some Data from a database. To do so, I implemente a class called DataProvider which handles the database access. </p>
  
  <p>Now I added this DataProvider class to my HelloWorld class, which is my Controller here. As soon as I do that, i get the following exception:</p>
  
  <pre><code>java.lang.IllegalStateException: ApplicationObjectSupport instance [de.bpm.keza.ui.srv.kennzahlen.controller.HelloController@7361b599] does not run in an ApplicationContext
  </code></pre>
  
  <p>Here is my Dispatcher-Servlet:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
  
         http://www.springframework.org/schema/beans     
         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context 
         http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
     &lt;context:component-scan base-package="de.bpm.keza.ui.srv.kennzahlen" /&gt;
  
     &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
        &lt;property name="prefix" value="/WEB-INF/templates/" /&gt;
        &lt;property name="suffix" value=".jsp" /&gt;
     &lt;/bean&gt;
  
      &lt;!-- Externe Konfigurationsdateien --&gt;
      &lt;bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
          &lt;property name="jndiName"  value="jdbc/BPM_KORE_ALIAS"/&gt;
      &lt;/bean&gt;
  
      &lt;!-- DataProvider --&gt;
      &lt;bean id="dataProvider" class="de.bpm.keza.ui.srv.kennzahlen.data.DataProvider"&gt;
          &lt;property name="dataSource"&gt;
              &lt;ref bean="dataSource" /&gt;
          &lt;/property&gt;
  
      &lt;!-- KEZA Dashboard --&gt;
      &lt;property name="koreVorgaengeGesamtDataSql"&gt;
              &lt;value&gt;
                  select 
                      *
                  from DE_BPM_KORE_DBRD
              &lt;/value&gt;
      &lt;/property&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>here is my HelloController.java</p>
  
  <pre><code>@Controller
  public class HelloController extends WebContentGenerator {
  
  
      DataProvider daPro = ((DataProvider) getWebApplicationContext().getBean("dataProvider", DataProvider.class));
  
     @RequestMapping("/hello")
      public ModelAndView helloWorld() {
          String message = "Hello World, Spring 3.0!";
          return new ModelAndView("hello", "message", message);
      }
  
     @RequestMapping("/bye")
      public ModelAndView byeWorld() {
          String message = "Goodbye World, Spring 3.0!";
  
  //          daPro.getVorgaengeGesamtByArkNr();
  
          return new ModelAndView("hello", "message", message);
      }
  </code></pre>
  
  <p>}</p>
  
  <p>What am i doing wrong here?</p>