Can anyone help explain why JNDI should be a preferred way to expose services such as a database / jms?
The posts I run into all talk about the advantage of not having to load a specific driver manager, benifiting from connection pooling etc. but thats easily achievable by specifying the driver manager in a properties file and using reflection.
Connection pooling can also be achieved by wiring in the right implementation into an application bean via spring or otherwise.
So why would using JNDI be any better?
JNDI really shines when you have to move an application between environments: development to integration to test to production. If you configure each app server to use the same JNDI name, you can have different databases in each environment and not have to change your code. You just pick up the WAR file and drop it in the new environment.
Here are some other assumptions that are crucial to know when judging this answer:
Perhaps you don't see this benefit because you're a lone developer who writes code on a local desktop and deploys right to production.