The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

ghazala (3) [Avatar] Offline
#1
Hi,

My question is regarding dependency injection . Just wondering all the client code in your examples is using JNDI lookup to call EJB ,and its written in the book that EJB component can be injected in any registered component in container i.e JSF backing bean or servlet or any other component.

I tried to access the EJB in client program outside the main method using dependency injection and it gives me NullPointerException .I have seen an example of sun j2ee tutorial website where they are injecting an EJB inside client program outside the main method.

So is there anything else need to be setup to call an EJB inclient code?

Thanks.
Susan-mhy (11) [Avatar] Offline
#2
Re: Using @EJB notation in client application ?
I think dependency injection needs some framework (like spring) to control your own code. So that it can inject when construct an instance. In chapter 2.3.4, it use ACC to do so
reza_rahman (456) [Avatar] Offline
#3
Re: Using @EJB notation in client application ?
Folks,

Kindly look at previous posts first before making new ones. As such, this is a pretty mature forum where basic questions like using @EJB in the JBoss 4.2 example code has already been answered.

JBoss 4.2 is not a full Java EE 5 container and does not support @EJB. JBoss 5 (which we do not have code examples for) and GlassFish v1/WebLogic 10/Oracle AS do (which we do have code examples for).

Cheers,
Reza