title: JDBC Connection using JNDI : Name Clash?
body: <p>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.</p>
  
  <p>With some combinations of name I get the folllowing:</p>
  
  <blockquote>
    <p>java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp2.BasicDataSource cannot be cast to javax.naming.Context</p>
  </blockquote>
  
  <p>Can someone explain why it doesn't work if I have 2 resources with names like:</p>
  
  <pre><code>name="jdbc/postgres/1/2/3/4/5"
  name="jdbc/postgres/1/2/3/4/5/6"
  </code></pre>
  
  <p>But changing the second name to this does work:</p>
  
  <pre><code>name="jdbc/postgres/1/2/3/4/4/6"
  </code></pre>
  
  <p>Thanks.</p>