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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:41:07+00:00 2026-05-26T00:41:07+00:00

I want to write an application which has 2 EJBs. This application can run

  • 0

I want to write an application which has 2 EJBs. This application can run in both OpenEJB and WebLogic 10.3. Both of the EJB are EJB 3.0.

I know how to implement in both OpenEJB and WebLogic, but the problem is I want to use the same code to deploy to both environments. I think the problem is that how to do JNDI lookup, because WebLogic’s Context.INITIAL_CONTEXT_FACTORY is weblogic.jndi.WLInitialContextFactory but OpenEJB is not.

Current idea is the 1st EJB use a service locator to lookup the 2nd EJB and the service locator will read different INI in 2 environments. Is there any other suggestion? Is there a solution I can just use annotation, no need to use external INI files.

The 2 EJBs live in one container, but it’s possible one will be move to other container in the future.

Update on 2011/10/06

By David’s suggestion, I put some change. The code is a POJO, not JUnit code. It doesn’t use @LocalClient and initialContext.bind(“inject”, this); (I put the 2 code in my JUnit code)

  1. Put resources\META-INF\application-client.xml (only contain )

  2. Put resources\jndi.properties

    jdbc/OrderDB = new://Resource?type=DataSource
    jdbc/OrderDB.JdbcDriver = oracle.jdbc.OracleDriver
    jdbc/OrderDB.JdbcUrl = jdbc:oracle:thin:@*.*.*.*:1521:test
    jdbc/OrderDB.JtaManaged = false
    jdbc/OrderDB.UserName = test
    jdbc/OrderDB.Password = test
    
  3. Lookup code

    InitialContext ctx= new InitialContext();
    ctx.lookup("jdbc/" + name);
    

The following is the log, OpenEJB creates the JNDI for the database. I also use Eclipse debug mode to see the content of “ctx” and find “jdbc/OrderDB” in MyProps

INFO - Configuring Service(id=jdbc/OrderDB, type=Resource, provider-id=Default JDBC Database)

But finally I still cannot lookup it. I also try to use ctx.lookup(name), ctx.lookup(“java:comp/env/jdbc/” + name) and the result is the same.

javax.naming.NameNotFoundException: Name "jdbc/OrderDB" not found.

Update on 2011/10/12

Base on David’s comment, before Java EE6, I think the only solution is to use a service locator and some configuration to use different JNDI between WebLogic and OpenEJB. The following is the test result.

DB: WebLogic: OrderDB, OpenEJB: openejb:Resource/jdbc/OrderDB

Transaction manager: WebLogic: javax.transaction.TransactionManager, OpenEJB: java:comp/TransactionManager

EJB: Both of them just lookup the EJB name without any prefix

  • 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-26T00:41:07+00:00Added an answer on May 26, 2026 at 12:41 am

    The question in the update is a very different question, so posting a different answer.

    No Global JNDI prior to Java EE 6

    The long and short of it is that prior to Java EE 6, there is no global JNDI. So it is quite literally the case that the question “what is the JNDI name of x” is an unanswerable question. Each EJB has its own private JNDI namespace and “POJOs” don’t have any namespace at all, they use the JNDI namespace of whatever EJB invoked it. So to make “java:comp/env/myDataSource” appear as global as possible, you have to declare that reference for every single EJB in the application.

    The amount of configuration work this creates for users is quite devastating. In Java EE 6 there is finally Global JNDI and three new standard namespaces, java:module, java:app and java:global. Any Global JNDI functionality existing prior to Java EE 6 is vendor-specific and non-portable.

    The vendor-specific and non-portable way to do a Global JNDI lookup in OpenEJB for the given name would be to lookup openejb:Resource/jdbc/OrderDB

    Calling a spade a spade

    In OpenEJB we deliberately do not support non-standard lookups like jdbc/OrderDB or java:jdbc/OrderDB as some vendors do. The required prefix for global names in OpenEJB is openejb:.

    JNDI is complex and confusing enough and making non-portable names look like portable names doesn’t do users any favors. If a certain style of naming is not portable and going to create vendor lock-in, it should look like it. So with the openejb: prefix, you can access anything you need globally but it is at least clear that what you are doing is not portable and should not be expected to work in other platforms without some modification.

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

Sidebar

Related Questions

I want to write an application which can update an twitter status of an
I want to write a android application which needs data from the web. This
I have written a application which runs in the background. I want to write
I want to write a file where an external application can read it, but
This question has been already asked, but never answered. I want to write some
I want to write a basic application in which when the User press enter
I'm developing an application which has to run on Linux and Windows. I have
I want to write an application which should be able to connect to multiple
I have a web application which has a calendar, and I want to allow
I want to build a hadoop application which can read words from one file

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.