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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:05:36+00:00 2026-05-27T23:05:36+00:00

If a method of an EJB makes a JNDI lookup to the same EJB

  • 0

If a method of an EJB makes a JNDI lookup to the same EJB and then executes some other method, is this guaranteed to be executed in the same thread? How about the actual instance of the EJB object; is it the same instance as the one used in the calling method?

  • 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-27T23:05:37+00:00Added an answer on May 27, 2026 at 11:05 pm

    The EJB specification makes no restriction as to the possibility of injecting an EJB into itself (see EJB 3.1 spec, chapter 16.5.1.1):

    The [@EJB] reference may be to a session bean’s business interface or to a session bean’s no-interface view or to the local home interface or remote home interface of a session bean or entity bean.

    As with every EJB call, it will always be executed in the same thread; based on the Non-reentrant instances rule, it must not be the same instance (chapter 4.10.13):

    […] Stateful and stateless session beans do not have to be coded as reentrant. One implication of this rule is that an application cannot make loopback calls to a stateless or stateful session bean instance.

    This means: if bean A invokes a method on bean B, and B invokes any method on A, the container has to make sure that B calls another instance of A; the fact that it’s the same thread doesn’t matter, as reentrancy and thread-safety are different things.

    The same situation applies when A calls itself through a looked-up JNDI reference, as container is involved at runtime in looking for a free instance of A. Conversely, if A directly invokes one of its methods, it’s a simple Java method invocation on “this”, not involving the container.

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

Sidebar

Related Questions

I'm working with EJB 3.0 and when I call the method to be executed,
I have some code along the lines of this: @EJB protected SomeService service; //
I have an @Stateless EJB method in which I delete some entries from a
I have an EJB, whose method (among other things) load an entity and modify
I have a remote EJB with a method that validates an object (returning true
What method do you use when you want to get performance data about specific
Is it possible to invoke a transactional method from within a Stateful EJB itself?
I am new to EJB. I have a requirement of calling a method of
I have a ConfigParameter SLSB that reads configuration values from the ejb-jar.xml file. This
I'm trying to create an EJB factory class, which works like this: You have

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.