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.xml
with the java:app/
scope prefix. According to that document:
If the resource definition is provided within an archive (ie., glassfish-resources.xml within an .ear or other archives), they are assumed to be scoped resources.
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.xml
or (in my case) it is a WAR and the path is WEB-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.