8

I've noticed that both ways of looking up a DataSource using JNDI work:

  1. jdbc/DataSource
  2. java:comp/env/jdbc/DataSource

With the added bonus that the first one doesn't seem to anger Websphere when used from an unmanaged thread ( started by Quartz ).

Are there any pitfalls from accessing JNDI objects without the prefix?

Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278

1 Answers1

5

This should be OK, since java:comp/env is the global JNDI namespace. It may depend on the application server where such configurations also appear in the JNDI tree.

Locate your JDBC DataSource in WebSphere Application Server using JNDI

PaoloC
  • 3,817
  • 1
  • 23
  • 27
stacker
  • 68,052
  • 28
  • 140
  • 210
  • Thanks. I think that the link is broken. – Robert Munteanu Aug 10 '10 at 09:53
  • 1
    java:comp/env doesn't work if you are coming from a (non-container) application (at least with WebSphere). So then you have to stick to the first name when looking up the resource. – Chris Aldrich Sep 24 '10 at 20:11
  • 1
    Same thing with WebLogic, where it affects lookup from any thread that is not directly managed by the container. For example, from a WLS thread you can use "java:comp/env/jmx/runtime" but from a non-WLS thread you must lookup "java:comp/jmx/runtime". – torngat Feb 20 '12 at 18:28