According to this article and a number of other documents, JDBC resources are deployed globally (available server-wide) unless prefixed with java:app/. When I change jdbc/myDataSource to java:app/jdbc/myDataSource and myConnectionPool to java:app/myConnectionPool, deployment fails with this exception:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : { ResourceInfo : (jndiName=java:app/jdbc/myDataSource__pm), (applicationName=com.example.web_example_war_1.0-SNAPSHOT) }
It works just fine without the java:app/ prefixes, but then the resources are deployed server-wide.
After reading this section, I realised that I don’t have to prefix resources defined in
glassfish-resources.xmlwith thejava:app/scope prefix. According to that document:And then it goes on to say the resources are application scoped if the application is an EAR and the path is
META-INF/glassfish-resources.xmlor (in my case) it is a WAR and the path isWEB-INF/glassfish-resources.xml.This may explain why GlassFish was mangling the name. There was most likely a name collision because I added the prefix.