title: Naming error while using multiple connection pools in a Tomcat 8 application
body: <p>I have an application that uses the built-in Tomcat connection pool, and for the most part it works. A problem arises when I'm trying to use another pool to get a different set of connection from the same database, but from a different username/password (It's an oracle database that uses 2 usernames to access different namespaces of tables and function).</p>
  
  <p>The first pool is accepted, but for the second one, I'm getting this error</p>
  
  <pre><code>15:09:47.157 [http-nio-8081-exec-5] ERROR com.applicationname.providers.ConnectionManager - NamingException in MyDataSource
  javax.naming.NameNotFoundException: Name [appdb_two] is not bound in this Context. Unable to find [appdb_two].
      at org.apache.naming.NamingContext.lookup(NamingContext.java:818) ~[catalina.jar:8.0.15]
  </code></pre>
  
  <p>Here is my configuration:</p>
  
  <p><strong>server.xml</strong></p>
  
  <pre><code>&lt;GlobalNamingResources&gt;
      &lt;!-- Editable user database that can also be used by
      UserDatabaseRealm to authenticate users--&gt;
  
      &lt;Resource name="UserDatabase" 
                auth="Container"
                type="org.apache.catalina.UserDatabase"
                description="User database that can be updated and saved"
                factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
                pathname="conf/tomcat-users.xml" /&gt;
  
      &lt;Resource name="jdbc/appdb_two"
                auth="Container"
                type="javax.sql.DataSource"
                driverClassName="oracle.jdbc.driver.OracleDriver"
                factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"/&gt;
  
      &lt;Resource name="jdbc/appdb_one"
                auth="Container"
                type="javax.sql.DataSource"
                driverClassName="oracle.jdbc.driver.OracleDriver"
                factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"/&gt;
  
  &lt;/GlobalNamingResources&gt;
  </code></pre>
  
  <p><strong>context.xml</strong></p>
  
  <pre><code>&lt;ResourceLink name="jdbc/appdb_two" 
                auth="Container"             
                username="DBONE"
                password="xxxx" 
                type="javax.sql.DataSource" 
                url="jdbc:oracle:thin:@xx.xxx.xxx.xxx:1521:XE"
                initialSize="20"
                maxActive="50"
                maxIdle="20"
                factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"/&gt;
  
  &lt;ResourceLink name="jdbc/appdb_one" 
                auth="Container"
                username="DBTWO"
                password="xxxx" 
                type="javax.sql.DataSource" 
                url="jdbc:oracle:thin:@xx.xxx.xxx.xxx:1521:XE"
                initialSize="20"
                maxActive="50"
                maxIdle="20"
                factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"/&gt;
  ...
  </code></pre>