I'd suggest restructuring your code - making servlet methods transactional is not a good thing to do. Put the transactional logic in a separate, service class, and either
- obtain these spring-managed classes by
WebApplicationContextUtils.getRequiredWebApplicationContext().getBean(..)
or - in your servlet
init()
method obtain theApplicationContext
with the above method and callappCtx.getAutowireCapableBeanFactory().autowireBean(this)
. This way you can inject the transactional classes in your servlet as if it was spring-managed.
Now, you can do all this, but it is definitely not a beautiful way to go. I'd suggest using Spring MVC or any other MVC framework (which support spring integration of its components)
If this is all not possible, as a last resort I think you can use @Configurable
(on your servlets) with a <context:load-time-weaver/>
.