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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:14:11+00:00 2026-05-29T04:14:11+00:00

I am doing a Jndi look up using <jee:jndi-lookup> . Everything works fine but

  • 0

I am doing a Jndi look up using <jee:jndi-lookup> . Everything works fine but as per the Jndi resource reference in Tomcat site , we need the <resource-ref> in Web.xml . I am not able to understand why we need this. Everything works fine if I have a context.xml under the conf folder without the web.xml definitions .

My question is whether <resource-ref> is required only when we lookup Jndi through plain Java code(InitialContext().lookup("...")) and not via Spring .I am not sure if we need this here also.

I saw a discussion on this at What is resource-ref in web.xml used for? but the configuration below

<resource-ref>
  <res-ref-name>jdbc/primaryDB</res-ref-name>
  <jndi-name>jdbc/PrimaryDBInTheContainer</jndi-name>
</resource-ref>

does not seem to work as stated when I use it in the application’s web.xml(under WEB-INF) . I think it’s specific to JBoss web.xml. Please help me understand .

  • 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-29T04:14:11+00:00Added an answer on May 29, 2026 at 4:14 am

    Spring is plain Java code. It’s no black magic.

    Using a resource-ref is a good practice because it allows using a name that is local to the web app, rather than using a global name, shared by all the webapps in the container.

    Suppose that you want to deploy two different versions of the same app in the same container, and that both use the same global JNDI name. They’re now forced to use the same database, which is wrong. Whereas if you use a local name, declared in the web.xml file, you can associate each version with it own global name, and thus have both versions use two different databases.

    The same goes if you deploy two completely different applications, and both happen to use the same jdbc/OracleDS global name.

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

Sidebar

Related Questions

Doing an ajax get request works as expected using the following code: $.ajax({ type:
Doing a simple Squeryl database lookup, but trying to exclude a value. I've tried:
Doing this works in IE7: <a href= target=_blank>Link</a> But in IE8 it open a
Doing a web site using spring mvc. I added a SignupController to handle all
Doing code analysis of the project and get the message Reference-counted object is used
I'm trying to lookup a user on a local active-directory using java. When I
I am building a web application using Spring, Tomcat 7.0.27 and Atomikos 3.7.1. I
I have been doing some reading about the JBoss Naming Service JNDI provider. I
So far, I've implemented a little webapp with GWT, which works. But now I
I am doing tests on an ejb3-project using ejb3unit http://ejb3unit.sourceforge.net/Session-Bean.html for testing. All my

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.