I had to answer the same question to myself and pulled these links together.
In short, JNDI Naming Policies can be any but JEE defines its own:
JNDI is defined independent of any specific naming and
directory service implementation.
However, one important platform that does define a limited set of
naming policies for using the JNDI is ... JEE.
This would be the most conventional name for the datasource:
The enterprise namespace is rooted in a URL context for the java
URL scheme.
For example, a JDBC Salary
database might have the name "java:comp/env/jdbc/Salary
".
- ...
comp
is bound to a subtree reserved for component-related bindings.
- ...
env
is bound to a subtree that is reserved for the component's environment-related bindings, as defined by its deployment descriptor.
- Resource factory references are placed in subtrees differentiated by their resource manager type.
- ...
jdbc
for JDBC DataSource references.
JEE 7 Tutorial also details naming policies to reference EJBs in 32.4.1.1 Portable JNDI Syntax.
Note that @Resource
annotation to inject DataSource
often specifies JNDI name relative to java:comp/env
- see this answer or this answer for portable and deployable solutions.
As mentioned in your updated link, java:jboss
namespace is a custom extension provided by WildFly/JBoss only.
To answer the question, the sub-trees under standard namespaces are just normal hierarchy. Obviously, it only makes sense if these sub-trees are (widely) recognized by application server, documentation, processes, etc. Otherwise, I guess nearly flat key-value or random bananaboat/MyDS
is fine but still has to be "mounted" under supported namespace like java:jboss
.