Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ManagedBean with SessionBean?

 
nimo frey
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • 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??
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • 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!
 
Jair Rillo Junior
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic