Spring @Autowired en Servlet
Estoy usando Spring Framework (2.5.4) en mi aplicación con el tiempo de carga y todo funciona bien en todas partes (en Spring beans, en entidades que no son Spring), excepto cuando intento conectar automáticamente el campo en un servlet anotado como @Configurable, luego Me sale una buena NullPointerException ...
@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());
}
}
<context:load-time-weaver/>
<context:spring-configured/>
<context:component-scan base-package="cz.flexibla2" />
¿Alguna sugerencia sobre lo que estoy haciendo incorrectamente?
Gracias.