Trying to set up a couple of JDBC connections in the context.xml of my tomcat instance but struggling to understand why some names seem to clash.
With some combinations of name I get the folllowing:
java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp2.BasicDataSource cannot be cast to javax.naming.Context
Can someone explain why it doesn't work if I have 2 resources with names like:
But changing the second name to this does work:
Best How To :
According to the Tomcat doc, name is the JNDI name relative to the java:comp/env context. The full name is treated as a path with the elements separated by
In your example,
creates the data source node
5 under the path
then tries to create the data source node
6 at path
The exception occurs because Tomcat expects a path element (Context) at
5 but finds a data source instead.
In your working example, you create the data source
6 under the different path