• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

ManagedBean with SessionBean?

 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a kind of relationship how a sessionBean can interact with a managedBean?

I know SessionBeans lies in my EJB-Container and provide methods to other sessionBeans.

But what about my Servlet-Container? In there I have managedBeans and want access methods coming from my SessionBean. But how? With @EJB, it does not work.

Should I implement view-relevant logic in my sessionBean or should I copy these methods from my sessionBean out to my managedBean?

Can anyone tell me the purpose of sessionBean, when a Websystem cannot access these methods via their interface??
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by nimo frey:
Is there a kind of relationship how a sessionBean can interact with a managedBean?

I know SessionBeans lies in my EJB-Container and provide methods to other sessionBeans.

But what about my Servlet-Container? In there I have managedBeans and want access methods coming from my SessionBean. But how? With @EJB, it does not work.

Should I implement view-relevant logic in my sessionBean or should I copy these methods from my sessionBean out to my managedBean?

Can anyone tell me the purpose of sessionBean, when a Websystem cannot access these methods via their interface??



What type of managed bean are you talking about? An EJB Entity bean or..? Actually I just looked at the fact that you're talking about your servlet container, so I assume some sort of JSF managed bean?

Anyhow Session Beans are typically used to provide command and control (e.g. Workflow) and they should be callable from your web tier (servlets).

I assume you are using EJB 3.0? Can you show us the code you are using to talk to your session bean?
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I mean JSF-ManagedBeans (which are POJOs lying in my ServletContainer):

Look at the example:



My EJBs SessionBean:




But the @EJB-Injection in my JSF-Bean does not work, as I can use this Annotation only in other SessionBeans and not a JSF-Bean. Am I right?

How can I do that?
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My understanding is that it does work (Disclaimer: I'm not a JSF developer), try this article for some assistance.

Hope that helps!
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nimo, which application server are you using? If you're using JBoss 4.2.x forget!!, the @EJB annotation wasn't implemented yet (In version 5.x seems it was implemented, but I'm not 100% sure).
 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

yes I use(d) JBOSS 4.2.

Thanks!!
 
Jair Rillo Junior
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by nimo frey:
Hello,

yes I use(d) JBOSS 4.2.

Thanks!!



Try out Glassfish or JBoss 5.x. If you want to keep with JBoss 4.2 you must use JNDI to call the SessionBeans
 
I love a woman who dresses in stainless steel ... and carries tiny ads:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic