can spring inject EJBs into annotated fields of servlet in a Java SE webapp? -
spring has support injecting javax.ejb.ejb annotations
, injects @autowired
, other jsr-220 injection annotations, commonannotationbeanpostprocessor class.
however, injection doesn't work servlets, since servlet isn't created spring.
this article - spring injects servlets too - doesn't give example using servlets, claims it's possible using compile-time weaving of aspects. unfortunately, compile-time weaving not option us. possible @ runtime? it's ok introduce subclass servlet if helps, want keep ejb annotations servlets can still deployed in java ee container.
edit: app deployed java ee container in production, thinking of using spring running functional tests , local deployment development take advantage of hot jsp loading in tomcat.
you need java ee container in glassfish supports injection of ejbs , beware injection works on managed classes servlets, managed beans..etc (classes managed containers) ejb injection in normal classes require use lookups instead.
Comments
Post a Comment