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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:44:13+00:00 2026-05-25T14:44:13+00:00

I started exploring the possibilities of using OpenEJB in embedded mode for unit-testing my

  • 0

I started exploring the possibilities of using OpenEJB in embedded mode for unit-testing my EJB3 components. At first I got errors like the below output

Testsuite: HelloBeanTest
Tests run: 4, Failures: 0, Errors: 4, Time elapsed: 1,779 sec
------------- Standard Output ---------------
Apache OpenEJB 3.1.4    build: 20101112-03:32
http://openejb.apache.org/
------------- ---------------- ---------------
------------- Standard Error -----------------
log4j:WARN No appenders could be found for logger 
(org.apache.openejb.resource.activemq.ActiveMQResourceAdapter).
log4j:WARN Please initialize the log4j system properly.
------------- ---------------- ---------------

Testcase: sum took 1,758 sec
Caused an ERROR
Name "HelloBeanLocal" not found.
javax.naming.NameNotFoundException: Name "HelloBeanLocal" not found.
at org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:193)
at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:150)
at 
org.apache.openejb.core.ivm.naming.ContextWrapper.lookup(ContextWrapper.java:115)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at HelloBeanTest.bootContainer(Unknown Source)

# ... output is the same for all the rest of the tests

The openejb.home property is set as a system property and points to my OpenEJB installation dir.

The HelloBeanTest#bootContainer() is a setUp method and it fails on the JNDI lookup. Shown below.

@Before
  public void bootContainer() throws Exception{
    Properties props = new Properties();
    props.put(Context.INITIAL_CONTEXT_FACTORY,
             "org.apache.openejb.client.LocalInitialContextFactory");
    Context context = new InitialContext(props);
    hello = (Hello) context.lookup("HelloBeanLocal");

}

After struggling with problems like this I started to try out OpenEJB in non-embedded mode, and started the container from it’s installation directory and deployed the components as an ejb.jar. Deployment was successful and I started creating a stand-alone Java client. The stand-alone Java client is still unfinished, but meanwhile I came back to testing in embedded mode.

To my surprise, the tests suddenly started to pass. I added some more functionality to the component and tests for those. Everything worked just fine. Below is the output for that run.

Testsuite: HelloBeanTest
Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 2,281 sec
------------- Standard Output ---------------
Apache OpenEJB 3.1.4    build: 20101112-03:32
http://openejb.apache.org/
------------- ---------------- ---------------
------------- Standard Error -----------------
log4j:WARN No appenders could be found for logger
(org.apache.openejb.resource.activemq.ActiveMQResourceAdapter).
log4j:WARN Please initialize the log4j system properly.
------------- ---------------- ---------------

Testcase: sum took 2,263 sec
Testcase: hello took 0,001 sec
Testcase: sum2 took 0 sec
Testcase: avg took 0,001 sec

I was happily coding and testing until it broke again. It seems that removing the ejb.jar from /apps directory caused it. So, it seems that OpenEJB does the JNDI lookup still from the installation dir, but uses the current dir to find the actual implementations when running in embedded mode. I made this conclusion as the ejb.jar deployed in apps/ dir does not have all the methods that the local version has. (I double checked with javap.) Only the class signature is the same.

After this very long introduction, it’s question time.

  • Can anyone provide any explanation for this behaviour?
  • Packaging and deploying the EJBs in the apps/ dir before testing is simple task, but can I be sure that even then I am testing the correct implementation?
  • Does this all have something to do with the openejb.home property pointing at the OpenEJB installation dir?

For summary, OpenEJB version is Apache OpenEJB 3.1.4 build: 20101112-03:32, which is visible in the log outputs as well.

Thanks in advance.

  • 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-25T14:44:13+00:00Added an answer on May 25, 2026 at 2:44 pm

    It does have something to do with setting the openejb.home to point to the installation dir.

    There’s a conf/openejb.xml file that likely has a apps/ listed as where deployments live. All the log output went to the logs/ dir and not in System.out of the test case where you can read it easily.

    To use OpenEJB embedded you don’t need any config files, directories, or ports. You just include the libs in your project’s classpath.

    First thing I’d say is to check out the openejb-examples-3.1.4.zip. There are maybe two dozen example projects all setup with both Ant and Maven build scripts. All the examples will work in any environment as long as the OpenEJB libraries are in the classpath. Here’s a video of using one of the examples to unit test in Eclipse. I recommend the simple-stateless example as the best starting point.

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

Sidebar

Related Questions

I've recently started exploring using AJAX for a small project, and I've had reasonable
I have just started exploring Backbone.js. Upon submission of a form I would like
I have recently started exploring Maven, but I feel a bit overwhelmed of all
I started using subversion for one of my projects and it would be absolutely
I started programming C# applications when the 1.0 framework was first released. I worked
Just started getting a bunch of errors on our C# .Net app that seemed
I started exploring Google Guice today to do dependency injection in my application. I
Just started exploring Cocoa so pretty much a total noob. I've written a very
I have just started exploring TWILL . Twill is an amazing scripting language for
I just started exploring Java Servlets and JSP and am a little confused about

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.