Two Laptop Bag*
The moose likes EJB and other Java EE Technologies and the fly likes ManagedBean with SessionBean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ManagedBean with SessionBean?" Watch "ManagedBean with SessionBean?" New topic
Author

ManagedBean with SessionBean?

nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
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

Joined: Jun 24, 2003
Posts: 3274
    
    5

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?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
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

Joined: Jun 24, 2003
Posts: 3274
    
    5

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

Joined: Aug 27, 2008
Posts: 114
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).


Regards, Jair Rillo Junior
http://www.jairrillo.com/blog, SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 5.0, IBM SOA Associate (Test 664).
nimo frey
Ranch Hand

Joined: Jun 28, 2008
Posts: 580
Hello,

yes I use(d) JBOSS 4.2.

Thanks!!
Jair Rillo Junior
Ranch Hand

Joined: Aug 27, 2008
Posts: 114
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
 
jQuery in Action, 2nd edition
 
subject: ManagedBean with SessionBean?