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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:28:25+00:00 2026-06-01T18:28:25+00:00

I am working on an EJB 3 project using OpenEJB (TomEE++). I have a

  • 0

I am working on an EJB 3 project using OpenEJB (TomEE++).

I have a stateless session bean whose name has been specified with an annotation.

@Stateless(mappedName="SlideService", name="SlideService")
public class SlideService {

    public Map<Category, List<SlideShow>> fetchSlideShowsByCategory() {
        Application app = Application.getInstance();
        return app.retreiveAllSlideShowsByCategory();
    }

    public SlideShow fetchSlideShow(long id) {
        return null;
    }

    public List<SlideShow> fetchSlideShowsByTitle(String title) {
        return null;
    }

}

I lookup the Session bean from my Struts action class, like this.

Properties properties = new Properties();
properties.setProperty Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.LocalInitialContextFactory");
InitialContext initialContext = new InitialContext(properties);
SlideService slideService = (SlideService)initialContext.lookup("SlideServiceLocalBean");

In the code above you will notice that I have to use the name ‘SlideServiceLocalBean’, to locate the bean, whereas I have explicitly specified ‘SlideService’ in the bean’s annotation.

However, when I try to locate the bean in my test case I have to use yet another name string.

EJBContainer ejbContainer = EJBContainer.createEJBContainer();
Object oSlideService = ejbContainer.getContext().lookup("java:global/slides/SlideService");

Why is there a discrepancy in lookup names ?

Am I obtaining the InitialContext in the right way, in the Struts action class, or should I use another mechanism/contextFactory to get the initial context ?

Is it possible to have the bean injected in the action class without using an external DI library ?

  • 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-01T18:28:26+00:00Added an answer on June 1, 2026 at 6:28 pm

    Try this inside your struts action class:

    new InitialContext().lookup("java:global/slides/SlideService");
    

    It should work fine. So should this from inside the action class:

    new InitialContext().lookup("java:module/SlideService");
    

    The lookup using the LocalInitialContextFactory predates JavaEE 6 Global JNDI where these java:global and java:module names come from.

    This doc explains how it works.

    • http://openejb.apache.org/jndi-names.html

    Your bean’s name is SlideService and has what is called an @LocalBean view (a single bean can have many views such as @LocalBean, @Remote, @Local), so the name for looking up the SlideService as an @LocalBean ends up being SlideServiceLocalBean

    That’s just the default format. You can change it to whatever you like in the conf/system.properties file.

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

Sidebar

Related Questions

I am working on an EJB project with OpenEJB (TomEE++) container. There is a
I have been working in a Government Project using EJBs . I have found
I am using Tomcat & OpenEJB 3.1.4.Working with Message Driven Bean(EJB 2.0 - MDB)
I'm working on a web project using EJB 3.0, and whenever EclipseLink tries to
I've been working on a Java EE 6 project (EJB 3.1, JSF 2, JPA
I am about to start a web project and have been working almost exclusively
In the project I'm working on, we are using OpenEJB as a framework to
I am working on an enterprise project that has an EJB module and a
I have been working on a web project that stores locations for users. The
I have tried for hours to get my project working but the EJB part

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.