简体   繁体   中英

Calling @EJB from JSF Managed Bean

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

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

  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM