Today I spent half a day trying to deal with a similar problem. I have a tomcat server.xml file defining a context like this:
<Context docBase="app" path="/my_context_path"> </Context>
Then I tried to add support for the jdbc pool using org.apache.tomcat.jdbc.pool.DataSource.
Just added a resource definition to my server.xml server definition (see above). And for the reason I defined resource-ref in my web.xml.
But always the org.apache.tomcat.dbcp.dbcp.BasicDataSource file was returned. I spent time debugging tomcat and finally got to the following:
- If I define the resource in the context of server.xml - tomcat does NOT select this.
- If defined in a web archive, META-INF / context.xml is working fine.
- If you define GlobalNamingResources in the server.xml tag, tomcat will NOT select this.
- If you define the global context.xml file in tomcat, it works fine.
If you specify resource-ref in web.xml for bad cases 1,3 - tomcat will return org.apache.tomcat.dbcp.dbcp.BasicDataSource because I see that it is some kind of default. BUT using such a data source will lead to something like this:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
If you do not specify resource-ref in web.xml, you will get an exception indicating that a resource with this name cannot be found.
I also noticed that for good cases there is no need to specify the ref-resource in web.xml (works with and without the ref-resource).
Try some of the cases described. Hope something helps.
I would try to define a resource in the tomcat global context.xml file.
Good luck
Ps I am also running version 7.0.22.
source share