Re: Re: EJB injection issues from .WAR classes?
"Hans J. Prueller" <[email protected]> Mon, 07 Feb 2011 11:07:58 +0100
| Newsgroups | gmane.comp.java.objectweb.jonas |
|---|---|
| Organization | LBS logics GmbH |
| Message-ID | <1297073278.2009.8.camel@smithers> |
if injection is not performed by the container, EJB lookup should work via: Context.lookup(<mappedName>) when I declare my EJB's with: @Stateless(mappedName=<mappedName>) I think that should work in Web-Frameworks without container-based injection too ?? hans Am Montag, den 07.02.2011, 09:26 +0100 schrieb Guillaume Sauthier: > Hi Hans > > A Java EE container is only required to manager @EJB in Java EE > managed components (Servlet, Filter, ...). > Here you have an @EJB in some framework managed classes. > JOnAS (and any other container) will not inject anything for you here, > this is the job of the framework to do that. > > Maybe there is a webwork extension that will add support for this ? > > --G > > > Le 06/02/2011 09:50, Hans J. Prueller a écrit : > > > 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
(unnamed)
(image/png, 1 KB) - not displayed