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

  • Home
  • SEARCH
  • 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 6635091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:00:29+00:00 2026-05-25T23:00:29+00:00

In EJB2 , one needed to use getEJBBusinessObject() method in a EJB to pass

  • 0

In EJB2, one needed to use getEJBBusinessObject() method in a EJB to pass reference to itself when calling another (local/remote) bean.

Does the same apply for EJB3?

e.g.

@Stateless 
public class MyBean implements MyBeanLocal { 

    @Resource private SessionContext sessionContext; 

    public void myMethod() { 
        OtherBeanLocal  otherBean = ...; // getting reference to other local EJB. 
        MyBeanLocal myBean =  sessionContext.getBusinessObject(MyBeanLocal.class); 
        b.aMethod(myBean); 
    } 

    // Edit: calling myMethodTwo() from inside of myMethodOne()
    public void myMethodOne() {  
        MyBeanLocal myBean =  sessionContext.getBusinessObject(MyBeanLocal.class); 
        myBean.myMethodTwo(); 
    } 

    public void myMethodTwo() { 
        ...
    } 
    ... 
} 

Also, if I fetch my local bean using getBusinessObject() method, is it the same as if I use common JNDI lookup?

I’ve tested both approach, and both work, but I’m not sure if bean object is processed the same way by the container.

Edit:
Is fetching the reference to ejb itself, when calling myMethodTwo() from inside myMethodOne() of the same ejb, in EJB3, still needed? Is it allowed to call methods inside the same ejb through this reference?
How will this address transactions, if I decide to use some?

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

    Yes, the same applies to EJB 3. Yes, getBusinessObject is the EJB 3 analog to getEJBObject (or getEJBLocalObject). All of those methods return a proxy for the current bean object. For stateless session beans, this is basically the same as looking up through JNDI, though it’s likely to perform better since it avoids JNDI overhead.

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

Sidebar

Related Questions

Adding a new method to a stateless EJB(2.1) and promoting it to the Remote
I am calling a remote stateless session bean from a J2SE application and would
I recently started maintaining an old EJB2 application running on OC4J. That includes EJB
I have a session bean that uses Bean managed txns. This bean has one
In my study I faced EJB 2.0 and I don't understand how the bean
I'm upgrading an application from an old ejb2 setup to use ejb3's using the
i am trying to spawn multiple threads on an EJB 2.1 bean to test
I am using Tomcat & OpenEJB 3.1.4.Working with Message Driven Bean(EJB 2.0 - MDB)
I have an old EJB (2.1) project that uses xdoclet (1.2.3) to generate the
I have a large application that uses EJB 2.x entity beans (BMP). This is

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.