ghazala (3) [Avatar] Offline

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?

Susan-mhy (11) [Avatar] Offline
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
Re: Using @EJB notation in client application ?

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).