title: Cannot cast from ConnectionWrapper to oracle.jdbc.OracleConnection using JAVA1.8 and Tomcat 8.5.28
body: <p>Why connection is not working after few seconds? Application is hanging up and not running as expected and returning the below error.</p>
  
  <blockquote>
    <p>java.lang.ClassCastException:
    org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper
    cannot be cast to org.apache.tomcat.dbcp.dbcp2.DelegatingConnection</p>
  </blockquote>
  
  <p>Below is the code that is used to get the connection:</p>
  
  <pre><code>OracleConnection oracleConnection = (OracleConnection) 
  ((DelegatingConnection)connection).getInnermostDelegate();
  </code></pre>
  
  <p>using libraries: commons-pool1.6.jar for encryption &amp; tomcat-dbcp.jar for database.</p>
  
  <p>Using encrypted username and password in Tomcat context.xml.</p>
  
  <p>Also, using accessToUnderlyingConnectionAllowed=true in context.xml file.</p>
  
  <p>Issue is with JAVA8 and Tomcat8. Able to work properly with plain credentials, the only issue happens with encrypted credentials.</p>