Being hard headed, I persevered and was able to get this to work within <GlobalNamingResources>. I think there is some kind of issue when the default $CATALINA_HOME/Catalina/localhost/yourapp.xml file is created from the context.xml (found in the actual webapp deployment).
If you were like me and followed Sun's recommendations on setting up linkages, you put this in your context.xml file:
Code:
<Context path="/appdir" docBase="appdir" debug="0">
<ResourceLink name="jdbc/dbName" global="dbName" />
</Context>
Note this uses a relative directory for docBase because this is being deployed in a production system using a .war file and the full directory structure isn't known. Now it appears that, at least for me, Tomcat converted this into the following yourapp.xml file when it went about filling in the system specific information:
Code:
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="appName" docBase="D:\someGlobalPathStuff\appdir" path="/appdir"
workDir="work\Catalina\localhost\appdir">
<Resource auth="Container" name="jdbc/dbName" type="javax.sql.DataSource"/>
</Context>
Notice the <Resource ...> line. This does not work. Hmmm, as far as I could tell, it should have been this:
Code:
<ResourceLink auth="Container" name="jdbc/dbName" global="dbName"
type="javax.sql.DataSource"/>
Sure enough, change the <Resource ...> line to <ResourceLink global="dbName" ...> in yourapp.xml and it works.
For completeness, this was found on the following production Windows NT system:
[tt]
Tomcat V5.0.28
j2sdk1.4.1_01
mysql V4.0.18
[/tt]
and the following was in the web.xml file for the app:
Code:
<resource-ref>
<res-ref-name>jdbc/dbName</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
Hope this helps.