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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:30:05+00:00 2026-06-16T13:30:05+00:00

Its the first time I used the OpenEJB container system. When I use the

  • 0

Its the first time I used the OpenEJB container system. When I use the lockup-Method of the InitialContext, I get a NameNotFoundException. I’ve read lots of examples and tutorials and in every example the lookup method looks like:

initialContext.lookup("NameOfBean");

Now I’ve found another solution which uses the lookup like the following code snippet which works for me too.

initialContext.lookup("java:global/classpath.ear/ProjectName/NameofBean");

The question is why the first version doesn’t work for me and what I’ve done wrong?

Excerpts of the OpenEJB log:

INFO - ********************************************************************************
INFO - OpenEJB http://openejb.apache.org/
INFO - Startup: Sat Dec 22 13:17:59 CET 2012
INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
INFO - Version: 4.5.1
INFO - Build date: 20121209
INFO - Build time: 08:47
INFO - ********************************************************************************
INFO - openejb.home = D:\workspace\ProjectName
INFO - openejb.base = D:\workspace\ProjectName
INFO - Succeeded in installing singleton service
INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt to create  one for the beans deployed.
INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Using 'openejb.deployments.classpath.include=.*'
INFO - Found EjbModule in classpath: D:\workspace\ProjectName\build\classes
INFO - Searched 17 classpath urls in 2184 milliseconds.  Average 128 milliseconds per url.
INFO - Beginning load: D:\workspace\ProjectName\build\classes
INFO - Configuring enterprise application: D:\workspace\ProjectName\classpath.ear
WARNUNG - Method 'lookup' is not available for 'javax.annotation.Resource'. Probably using an older Runtime.
INFO - Auto-deploying ejb NameOfBean: EjbDeployment(deployment-id=NameOfBean)
[... AUTHORS'S NOTE: SOME MORE BEANS]
INFO - Assembling app: D:\workspace\ProjectName\classpath.ear
INFO - Hibernate Validator 4.2.0.Final
INFO - Ignoring XML configuration.
JAVA AGENT NOT INSTALLED. The JPA Persistence Provider requested installation of a ClassFileTransformer which requires a JavaAgent.  See http://openejb.apache.org/3.0/javaagent.html
INFO - OpenJPA dynamically loaded a validation provider.
INFO - Jndi(name=NameOfBeanRemote) --> Ejb(deployment-id=NameofBean)
INFO - Jndi(name=global/classpath.ear/ProjectName/NameOfBean!de.mypath.stateless.NameOfBeanInterface) --> Ejb(deployment-id=NameofBean)
INFO - Jndi(name=global/classpath.ear/ProjectName/NameofBean) --> Ejb(deployment-id=NameOfBean)
[... AUTHORS'S NOTE: SOME FOR OTHER BEANS]
INFO - OpenWebBeans Container is starting...
INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
INFO - All injection points are validated successfully.
INFO - OpenWebBeans Container has started, it took 250 ms.
INFO - Created Ejb(deployment-id=NameOfBean, ejb-name=NameOfBean, container=Default Stateless Container)
[... AUTHORS'S NOTE: SOME FOR OTHER BEANS]
INFO - Quartz scheduler 'OpenEJB-TimerService-Scheduler' initialized from an externally provided properties instance.
INFO - Quartz scheduler version: 2.1.6
INFO - Scheduler OpenEJB-TimerService-Scheduler_$_OpenEJB started.
INFO - Started Ejb(deployment-id=NameOfBean, ejb-name=NameOfBean, container=Default Stateless Container)
[... AUTHORS'S NOTE: SOME FOR OTHER BEANS]

This is my TestClass:

public class NamerOfBeanOpenEJBTest {

private static InitialContext initialContext;

@BeforeClass
public static void setUp() throws Exception {
       Properties properties = new Properties();
       properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
       properties.setProperty("openejb.deployments.classpath.include", ".*");
               initialContext = new InitialContext(properties);
}
@Test
public void testBean() throws NamingException{  
    Object object = initialContext.lookup("java:global/classpath.ear/ProjectName/NameOfBean");
    assertNotNull(object);
    assertTrue(object instanceof NameOfBean);
}

@AfterClass
public static void afterClass() throws Exception {
    if (initialContext != null) {
        initialContext.close();
    }}
}

Does someone have tipps or solutions for me?
Thanks a lot.

Edit:

In JBoss AS 7.1 the lookup can places like this example:

new InitialContext().lookup("ejb:/ProjectName//NameOfBean!de." + "mypath.sessionbean.stateless.NameOfBeanInterface");

Isnt that possible in OpenEJB? Do I have to change every lookup call in every bean to have a local test with OpenEJB? That wouldn’t be really effective and time-saving.

  • 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-16T13:30:06+00:00Added an answer on June 16, 2026 at 1:30 pm

    Problem solved!

    The strukture of the lookup is {deploymentId}{interfaceType.annotationName}. Therefore in my case it must be

    initialContext.lookup("NameOfBeanLocal");
    

    or
    initialContext.lookup(“NameOfBeanRemote”);
    depending on the type of the interface.

    To get the problem with JBoss solved you can switch from default lookup

    new InitialContext().lookup("ejb:/ProjectName//NameOfBean!de." + "mypath.sessionbean.stateless.NameOfBeanInterface");
    

    to something more flexible like Dependcy-Lookup or Dependency-Injection and use the @EJB annotation. Both ways are supportet by JBoss and OpenEJB.

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

Sidebar

Related Questions

Its my first time to use web service in iOS. REST was my first
first time I've used blat and it appears to work fine however its sending
I have an app, in that app if its the first time the user
I am trying to use SLF4J-Log4j for the first time. In every Java class,
first time questioner here. I'm currently struggling on how to use Beaker properly using
Its my first time using modal windows. And I'm currently using fancy box. But
I have never used Emacs before and the first time I tried it I
I just used this feature for the first time - in MS One Note
First time user of stackoverflow, but I have followed its development over on Coding
This is the first time I've used a for loop in iOS! Hurrah! Please

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.