0

We are using JDeveloper 11g. Both a Model and ViewController project that makes use of ADF fusion and what not.

My web-xml has an EJB reference for a stateful session EJB . I have a managed bean that's declared in faces-config.

I am trying to access a EJB from inside the managed bean.

I declare

@EJB (name ="LocationServicesEJB")
private LocationServicesEJB locationServices;

When accessing this in a method, the locationServices is null. I do not see any JNDI type problems in the console, so I imagine that it's not even bothering to lookup.

Do I need to enable injection or something? Or do I need to define 'locationServices' as managed property in my faces-config?

Please advise. Thanx

skaffman
  • 398,947
  • 96
  • 818
  • 769
guyumu
  • 3,457
  • 2
  • 19
  • 18

1 Answers1

1

You are confusing two different types of injection.

  1. There is EJB injection that happens among EJBs by the respective annotation. This type is handled by the EJB container (your application server or OpenEJB e.t.c)

  2. Then there is "normal" injection (ala Spring) that happens between normal Java beans and is defined in faces-config. This type is handled by JSF.

So decide what you want to do.

My proposal would be to download the official Java EE tutorial and skim through all topics.

kazanaki
  • 7,988
  • 8
  • 52
  • 79
  • thanx and sorry for only replying now. But yes you are right. I'll consider the tutorial... it's the adf stuff that's killing me – guyumu Aug 24 '09 at 18:04
  • The link in this answer is now broken, is it possible for you to revise it? – Tim Post Jun 08 '11 at 15:02
  • @kazanaki I am confused. Can't we inject EJB beans to (A)ManagedBean 's ( from JSF? ) ? http://stackoverflow.com/questions/8626291/jsf-managed-bean-ejb-injection?rq=1 In this example, it is successfully done? – Koray Tugay May 19 '13 at 20:52
  • In Java EE 5 is was not possible. In Java EE6 they introduced CDI (inspired from Seam) where you can inject anything to anything. When the original question was asked most people used Java EE 5 – kazanaki May 21 '13 at 08:55