title: Spring unable to read bean property from XML
body: <p>I'm having trouble setting a member value from my bean configuration XML. I've boiled this down to the simplest use case I could; the class here isn't intended to actually do anything. I noticed that the text value was never being set (always null), so I slapped a @Required on the setter method. This yields the BeanCreationException. Details here:</p>
  
  <p><a href="https://gist.github.com/arwagner/7268989" rel="nofollow">https://gist.github.com/arwagner/7268989</a></p>
  
  <p>Service class:</p>
  
  <pre><code>@Service
  public class FoobarService {
  private static final Logger logger = LoggerFactory.getLogger(FoobarService.class);
  private String text;
  
  public void report() {
      logger.info("text: " + getText());
  }
  
  public String getText() {
      return text;
  }
  
  @Required
  public void setText(String text) {
      logger.info("setText called");
      this.text = text;
  }
  }
  </code></pre>
  
  <p>Controller class:</p>
  
  <pre><code>@Controller
  public class HomeController {
  @Autowired
  private FoobarService foobarService;
  
  @RequestMapping(value = "/", method = RequestMethod.GET)
  public String home(Locale locale, Model model) {    
      foobarService.report();
      return "home";
  }
  }
  </code></pre>
  
  <p>root-context.xml:</p>
  
  <pre><code>...
  
  &lt;bean id="foobarService" class="com.agilex.onboardservices.services.FoobarService"&gt;
      &lt;property name="text" value="foobar"/&gt;
  &lt;/bean&gt;
  ...
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  metadata-complete="false"&gt;
  
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/root-context.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;!-- Creates the Spring Container shared by all Servlets and Filters --&gt;
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;!-- Processes application requests --&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/servlet-context.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p></p>
  
  <p>servlet-context.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans:beans xmlns="http://www.springframework.org/schema/mvc"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:beans="http://www.springframework.org/schema/beans"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
  &lt;annotation-driven /&gt;
  &lt;resources mapping="/resources/**" location="/resources/" /&gt;
  
  &lt;beans:bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"&gt;
      &lt;beans:property name="mediaTypes"&gt;
          &lt;beans:map&gt;
              &lt;beans:entry key="html" value="text/html" /&gt;
              &lt;beans:entry key="json" value="application/json" /&gt;
          &lt;/beans:map&gt;
      &lt;/beans:property&gt;
      &lt;beans:property name="viewResolvers"&gt;
          &lt;beans:list&gt;
              &lt;beans:bean class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
                  &lt;beans:property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /&gt;
                  &lt;beans:property name="prefix" value="/WEB-INF/views/" /&gt;
                  &lt;beans:property name="suffix" value=".jsp" /&gt;
              &lt;/beans:bean&gt;
          &lt;/beans:list&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  
  &lt;context:component-scan base-package="com.agilex.onboardservices" /&gt;
  &lt;/beans:beans&gt;
  </code></pre>