title: Cannot connect to Oracle 12c from Tomcat 6: no matching authentication protocol (ORA-28040)
body: <p>I have to connecto to an Oracle 12c database from Tomcat 6. I made a servlet that create a connection to this datasource (from <code>META-INF/context.xml</code>):</p>
  
  <pre><code>&lt;Context debug="0" docBase="/Test" path="/" reloadable="true"&gt;
     &lt;Resource
        name="jdbc/test" auth="Container" type="javax.sql.DataSource"
        driverClassName="oracle.jdbc.OracleDriver"
        url="jdbc:oracle:thin:@somewhere:someport:someservice"
        username="someuser" password="somepass" maxActive="10" maxIdle="5"
        maxWait="5000" removeAbandoned="true" removeAbandonedTimeout="60"
        logAbandoned="true"
     /&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p>When I create the connection using this code:</p>
  
  <pre><code>InitialContext initContext = new InitialContext();
  Context ctx = (Context) initContext.lookup("java:comp/env");
  DataSource ds = (DataSource) ctx.lookup("jdbc/test");
  conn = ds.getConnection();
  </code></pre>
  
  <p>I get the following exception:</p>
  
  <pre><code>org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (ORA-28040: No matching authentication protocol
  )
      at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
      at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
      at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
      at tomcattest.TestIt.doPost(TestIt.java:48)
      at tomcattest.TestIt.doGet(TestIt.java:27)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
      at java.lang.Thread.run(Thread.java:662)
  Caused by: java.sql.SQLException: ORA-28040: No matching authentication protocol
  
      at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:283)
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:278)
      at oracle.jdbc.driver.T4CTTIoauthenticate.receiveOsesskey(T4CTTIoauthenticate.java:294)
      at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:357)
      at oracle.jdbc.driver.PhysicalConnection.&lt;init&gt;(PhysicalConnection.java:441)
      at oracle.jdbc.driver.T4CConnection.&lt;init&gt;(T4CConnection.java:165)
      at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
      at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
      at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
      at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
      at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
      at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
      ... 18 more
  </code></pre>
  
  <p>But creating the connection with this code</p>
  
  <pre><code>Class.forName("oracle.jdbc.driver.OracleDriver");
  conn = DriverManager.getConnection("jdbc:oracle:thin:@somewhere:someport:someservice", "someuser", "somepass");
  </code></pre>
  
  <p>works fine; moreover, if I use an URL to an Oracle 11g database in the servlet, it works.</p>
  
  <p>I am using <code>ojdbc6.jar</code> driver for Oracle 12c, Tomcat 6, Java 1.6, Windows 7. Anyone have some hints?</p>