title: Spring @Autowired in Servlet
body: <p>I am using Spring framework (2.5.4) in my app with Load time weaving and everything works fine everywhere (in Spring beans, in non-Spring entities), except when I try to autowire field in a servlet annotated as @Configurable, then I get a nice NullPointerException...</p>
  
  <hr>
  
  <pre><code>@Configurable(dependencyCheck=true)
  public class CaptchaServlet extends HttpServlet{
      @Autowired
      private CaptchaServiceIface captchaService;
  
      @Override
      public void init(ServletConfig config) throws ServletException {
          super.init(config);
      //    ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
      //    captchaService = (CaptchaServiceIface) ctx.getBean("captchaService");
      }
  
      @Override
      protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
          Captcha c = captchaService.getCatpcha();
          req.getSession().setAttribute("captchaAnswer", c.getAnswer());
          resp.setContentType("image/png");
          ImageIO.write(c.getImage(), "png", resp.getOutputStream());
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;context:load-time-weaver/&gt;
  &lt;context:spring-configured/&gt;
  &lt;context:component-scan base-package="cz.flexibla2" /&gt;
  </code></pre>
  
  <p>Any suggestions about what am I doing incorrectly?</p>
  
  <p>Thanks.</p>