简体   繁体   English

从JSF托管Bean调用@EJB

[英]Calling @EJB from JSF Managed Bean

We are using JDeveloper 11g. 我们正在使用JDeveloper 11g。 Both a Model and ViewController project that makes use of ADF fusion and what not. 同时使用ADF融合的Model和ViewController项目。

My web-xml has an EJB reference for a stateful session EJB . 我的web-xml有一个有状态会话EJB的EJB参考。 I have a managed bean that's declared in faces-config. 我有一个在面孔配置中声明的托管bean。

I am trying to access a EJB from inside the managed bean. 我正在尝试从托管bean内部访问EJB。

I declare 我宣布

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

When accessing this in a method, the locationServices is null. 在方法中访问此方法时,locationServices为null。 I do not see any JNDI type problems in the console, so I imagine that it's not even bothering to lookup. 我在控制台中没有看到任何JNDI类型问题,因此我想它甚至不必费心查找。

Do I need to enable injection or something? 我需要启用注射功能吗? Or do I need to define 'locationServices' as managed property in my faces-config? 还是需要在“ faces-config”中将“ locationServices”定义为托管属性?

Please advise. 请指教。 Thanx 谢谢

You are confusing two different types of injection. 您在混淆两种不同类型的注入。

  1. There is EJB injection that happens among EJBs by the respective annotation. 通过相应的注释,EJB之间会发生EJB注入。 This type is handled by the EJB container (your application server or OpenEJB etc) 此类型由EJB容器(您的应用程序服务器或OpenEJB等)处理。

  2. Then there is "normal" injection (ala Spring) that happens between normal Java beans and is defined in faces-config. 然后在普通Java Bean之间发生“普通”注入(ala Spring),并在faces-config中定义。 This type is handled by JSF. 此类型由JSF处理。

So decide what you want to do. 因此,决定要做什么。

My proposal would be to download the official Java EE tutorial and skim through all topics. 我的建议是下载官方Java EE教程并浏览所有主题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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