I have the following entries in my Tomcat 9.0 server.xml:
In my web application, I have the following configured in web.xml:
I have defined a ServletContextListener roughly as follows:
The code runs, and when it does, the println() statements correctly print out the values from the web application's web.xml and the server's server.xml. Furthermore, when I inspect the environmentContext variable during debugging, I can see both environment entries.
The problem comes when I comment out the @Resource annotation on the dataDirectory property. The application fails to start with this message:
javax.naming.NameNotFoundException: Name [DataDirectory] is not bound in this Context. Unable to find [DataDirectory].
What is it about global naming resources that prevents me from using the @Resource annotation?