stateless session bean

Discussions

EJB programming & troubleshooting: stateless session bean

  1. stateless session bean (3 messages)

    Hi,
    I am a newbie to EJB stuff. Can I call stateful/enity bean from a stateless session bean? I mean inside a method can we call it?

    If yes, can anyone tell me in detail how this will work?

    Thanks in advance!
    Bhaskar
    Knowledge shared is knowledge gained!

    Threaded Messages (3)

  2. stateless session bean[ Go to top ]

    Yes of course you can...the Session Facade does exactly this. Your Session bean is a client to other beans in your system, just as any other client. You can also make use of local interfaces and resource references when invoking EJB's from other EJB's in the same container.

    you can setup a resource reference to an EJB and then use java:comp/env/some-name to access it from aonther EJB in the same container.
  3. stateless session bean[ Go to top ]

    Thanks for the reply. But how stateless bean will be managed in pool. Because, it has connection to stateful session bean?

    Can you please clarify more?

    Thanks
    Bhaskar
    Knowledge share dis knowledge gained!
  4. stateless session bean[ Go to top ]

    Well, at first glance, it seems strange to have a Stateless bean hang onto a reference to a Stateful bean. The reverse of that makes sense but not what youve mentioned does not. I think you either want your clients to deal with a Stateless bean OR a Stateful bean (if you need to track state on subsequent calls). I dont see any benefit of using a Stateless bean as a facade to a Stateful bean...just go straight to the Stateful bean. In fact, you'll actually lose any state your trying to keep if your client code doesnt hang onto the Stateful bean's home or handle directly. Your client code will never actually know which Stateful bean is being used if its hidden behind a Stateless bean.

    Does that make sense? If I have assumed to much about your app and you truly need to have Stateless bean use a Stateful bean, then its sounds tricky. Good luck ;)