title: @Autowired doesn't work when using Jersey with Spring
body: <p>I am trying to use Jersey with Spring. But for the life of me, I can't figure out why my Spring dependencies aren't being injected into my Rest Class.</p>
  
  <p>Each time I try and invoke the autowired dependency I get NULL. Can anyone suggest why my dependency isn't being injected?</p>
  
  <p>My Rest Class looks like this:</p>
  
  <pre><code>com.myapp.rest
  
  @Component
  @Scope("request") 
  @Path("/home")
  public class ChartResource {
  
  @Autowired
  ChartService chartService;
  
  @GET
  @Path("/chart")
  @Produces(APPLICATION_JSON)
  public Bean getChart() {
          return chartService.retrieveChart();
  
  
  }
  </code></pre>
  
  <p>My web.xml file looks like this</p>
  
  <pre><code>&lt;servlet&gt;
      &lt;servlet-name&gt;myapp&lt;/servlet-name&gt;
      &lt;servlet-class&gt;com.sun.jersey.spi.spring.container.servlet.SpringServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
          &lt;param-value&gt;org.codehaus.jackson.jaxrs;com.myapp.rest&lt;/param-value&gt;
      &lt;/init-param&gt;       
      &lt;init-param&gt;
          &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
          &lt;param-value&gt;org.codehaus.jackson.jaxrs&lt;/param-value&gt;
      &lt;/init-param&gt;   
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  </code></pre>
  
  <p>My applicationContext.xml is standard, and specifies the base package for component scanning:</p>
  
  <pre><code>&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-3.0.xsd
      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;annotation-driven /&gt;
  &lt;resources mapping="/resources/**" location="/resources/" /&gt;
  
  
  &lt;context:component-scan base-package="com.myapp" /&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>