• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can I inject ejb into managed bean?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic