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 8948415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:58:54+00:00 2026-06-15T12:58:54+00:00

I think I’m having a basic understanding problem here and I hope someone can

  • 0

I think I’m having a basic understanding problem here and I hope someone can explain this to me.

Lets say we have a stateful EJB_A and a stateful EJB_B and a sessionscoped ManagedbeanA:

@Stateful
@LocalBean
public class EJB_A {
}

@Stateful
@LocalBean
public class EJB_B {
  @EJB
  EJB_A ejb;
}
@ManagedBean
@SessionScoped
public class ManagedBeanA {
   @EJB
   EJB_A ejb;
}

In the ManagedBeanA, the EJB_A is created. Now when I use the EJB_B, which has the EJB_A as a property, a new instance of the EJB_A is created within the EJB_B. It is not the same instance of EJB_A that was created in the ManagedBeanA before.

I don’t understand that, because I thought the whole point of stateful EJBs is, that for each client only one instance is created and shared and managed by the EJB-Container. Can someone please explain this to me? And please also explain how I can achieve that the same instance of an EJB is shared by multiple other EJBs?

Thank you

  • 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-06-15T12:58:56+00:00Added an answer on June 15, 2026 at 12:58 pm

    Yes, you mixed up different concepts, and different APIS too…
    I’d rather use @Inject over @EJB and specify the scope of the injected instance..

    @Stateful
    @LocalBean
    public class EJB_A {
    }
    
    @Stateful
    @LocalBean
    public class EJB_B {
      @Inject @SessionScoped
      EJB_A ejb;
    }
    @ManagedBean
    @SessionScoped
    public class ManagedBeanA {
       @Inject @SessionScoped
       EJB_A ejb;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I have a basic understanding of this, but am hoping that someone
I think I have a fairly basic question here. I'm not trying to waste
Think I have an integer array like this: a[0]=60; a[1]=321; a[2]=5; now I want
I think this could be a very easy question for you. But I have
Think 2 entities OneToOne mapped. Person and Car. A Person can have a Car.
Think that I have many activities,and all I want is this: I have a
I think most people here understand the importance of fully automated builds. The problem
Think at this scenario: I have a c# windows form application. This application was
I think this is more of my lack of understanding the intricacy of Types
I think my PHP intall might have problems. When I try to do this

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.