EJB injection issues from .WAR classes?

"Hans J. Prueller" <[email protected]> Sun, 06 Feb 2011 09:50:38 +0100
Newsgroups gmane.comp.java.objectweb.jonas
Organization LBS logics GmbH
Message-ID <1296982238.2221.17.camel@kodos>
Hi JOnAS Team!

Meanwhile I have set up a Testproject and (partially) migrated  our Java
EE 1.4 based EAR  to Java EE 5 (finally!).
Basically things work, I can deploy the EAR to JOnAS 5.2 with success.


One major problem I have is that the injection of EJB's into
the .WAR-File classes not always works and I do not know why ?


E.g. there are 2 classes in the WAR file, in one case the EJB injection
works in the other case NOT (the reference to the EJB simply is NULL all
the time):

case 1)  classical Servlet class (Extends HttpServlet)  IMSAppServ.java:

member variable:

@EJB
static 	IMSSystem imssys;


-- when accessing imssys in doGet etc. methods -- it is already injected
correctly  and I can invoke the EJB methods (SLSB)


case 2)  we are using WebWork as WebApp Framework instead of "pure
servlet programming", something similar to struts. webwork
handles requests in so called "Action classes"; there is for instance
the "HomeAction.java":

member variable:
@EJB
 IMSSystem imssys;

--- when accessing imssys in the "execute" method of the action class,
it ALWAYS IS NULL   and causes NPE's  and follow up errors ... 




I assumed that the EJB's  should be injected anywhere I put the @EJB
annotation in one of the classes contained in the WAR -- am I wrong
with this ? so what is required to get working @EJB injections also in
our WebWork based or any other classes ?

as I didn't found much in the docs regarding this issue,  help is
appreciated!  ;-)

regards,
HANS
face-wink.png (image/png, 1 KB) - not displayed