This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JSF and the fly likes can I inject ejb into managed bean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "can I inject ejb into managed bean?" Watch "can I inject ejb into managed bean?" New topic
Author

can I inject ejb into managed bean?

Jiaxu Gu
Greenhorn

Joined: Oct 29, 2005
Posts: 12
I tried to inject a stateless session bean into the JSF managed bean using netbeans 6.1+glassfish v2.
First I create an enterprise application with an ejb module and a web module,then create a Remote stateless session bean in the ejb module,and add a business method.
Next I add JSF Framework to the web module and add a java class and using netbeans context menu to config it as the managed bean in the face-config.xml,then I open the managed bean class and select context menu :enterprise resource->call enterprise bean and select the session bean I created. After that these two lines add to the file

but when I use the managed bean , I found the testBean is null.

I have search the web and found some usage(DI) like this,
Are there something wrong with what I'm doing?

ps:I know the Seam framework and the jndi lookup can fix it,
but here I just want to know why can't I inject ejb into my managed bean?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16098
    
  21

The JSF bean manager isn't as comprehensive as something like Spring. It's intended to create POJOs via no-argument constructors, not via factory/finder techniques. That's your first problem.

I'm not sure, but the idea of injecting a stateless session bean sounds questionable, anyway. Normally, as I recall (they haven't let me use EJBs where I work), a stateless session EJB is acquired from a pool, used, and released fairly quickly, not locked down and held. So, while injecting a SSEJB into a Request-scope object is OK, it wouldn't be suitable for a Session or Application scope object.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can I inject ejb into managed bean?