Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 439967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:49:33+00:00 2026-05-12T20:49:33+00:00

I’m learning EJB3 and I’m just curious when it’s convenient to use SFSB? I

  • 0

I’m learning EJB3 and I’m just curious when it’s convenient to use SFSB? I can’t find any nice example when SFSB realy solve easily some complex problem.

Actually I see that SLSB can be used as web-services and this is convenient. But I don’t know when to use SFSB. I see only problems with it, because we should learn something about it, we should write code which consists of annotations a bit less then completely, we should use annoying lookup … and we don’t get anything good in return.

For example, we can’t use SFSB from SLSB, because stateful objects can be used only from stateful context. We can’t use DI in servlets, instead we should manually create SFSB instances using a JNDI lookup and then put it into the HttpSession object. It can’t be a web-service.

The only benefit I can see in SFSB is a transaction management. But I think it’s rare case when we really need a transaction and we don’t need DB. I can imagine that it can be really useful, when we store our data in an XML file and use transaction management in SFSB to manage non-relational DB.

I’m almost sure that I’m totally wrong, so give me some really nice examples of SFSB usage.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:49:34+00:00Added an answer on May 12, 2026 at 8:49 pm

    I’m learning ejb3 and I’m just curious when it’s convinient to use SFSB? I can’t find any nice example when SFSB realy solve easily some complex problem.

    You mean like a shopping cart? That’s the obvious answer that I can think of.

    Actually I see that SLSB can be used as web-services and this is convenient.

    You can think of EJBs as one way to deploy distributed services, but be careful. The term “web services” makes most people think of “SOAP-based web services using HTTP protocol”, and that’s not what you have in a SFSB.

    But I don’t know when to use SFSB. I see only problems with it because we should learn something about it, we should write code which consists of annotations a bit less then completely, we should use annoying lookup.. And we don’t get anything good in return.

    This paragraph is confusing, but I think you’re saying you don’t like EJBs much.

    For example, we can’t use SFSB from SLSB because stateful objects can be used only from stateful context.

    Right, they’re complementary. You use SFSB for use cases that require – wait for it – state to be maintained between calls.

    We can’t use DI in servlets, instead of it we should manually create SFSB instance using lookup and then put it to HttpSession object. It can’t be a web-service.

    Where did servlets come from here?

    The only profit I can see in SFSB is a transaction management. But I think it’s rare case when we really need a transaction and we don’t need DB. I can suppose that it can be realy useful when we store our data in xml-file and use transaction management in SFSB to simulate nonrelational DB.

    I think you’re totally off base here. Sessions beans are the ones that know about units of work and managing transactions. They probably have to work with entity beans to persist some of that state when the use case is done, so transactions aren’t as uncommon as you seem to think.

    I’m almost sure that I’m totally wrong, so give me some realy nice examples of SFSB usage.

    What’s your expectation? That someone will post working SFSB? I’m not going to do that, mostly because I’m not a big EJB fan. (I do everything you’re alluding to and more with Spring.)

    But rest assured that SFSB are sometimes useful. The shopping cart is the obvious example. You need a place to maintain items in the cart until the customer decides to purchase. SFSB is one way to accomplish that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.