Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Failed to validate a newly established connection

 
Dean Thomsen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an app that uses a jdbc connection pool to an Oracle database. I have successfully deployed to a localhost Tomcat 7 and to a linux server running Tomcat 7. When I deploy the same app (same jar) to Tomcat 8 I get this error (Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Failed to validate a newly established connection) when trying to connect to the database. I have validated that the required Database Driver jars are in the tomcat/lib directory.

I would appreciate any ideas about where to look to resolve this issue.

Thanks

Stack Trace
Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Failed to validate a newly established connection.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:26)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:111)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
... 54 more
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Failed to validate a newly established connection.
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:81)
at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67)
at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:279)
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:72)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:59)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:137)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:96)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:77)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
... 61 more
Caused by: java.sql.SQLException: Failed to validate a newly established connection.
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:802)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:617)
at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:186)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:127)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
... 71 more

context.xml

 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dean Thomsen,

First of all, a warm welcome to CodeRanch!

Dean Thomsen wrote:I would appreciate any ideas about where to look to resolve this issue.

Based on the exception message, I assume there's something wrong with the validation queries in your resources configuration in context.xml.

You are using 2 different databases (Oracle and SQL Server), but you are using the same validation query which could be causing this exception. Could you try with the following validation queries?
  • Oracle: SELECT 1 FROM DUAL
  • SQL Server: SELECT 1

  • Or you could of course (temporarily) remove the validationQuery and validationInterval as well.

    Hope it helps!
    Kind regards,
    Roel
     
    Dean Thomsen
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for the warm welcome, and DOH! how did I miss that? I was so focused on trying to find differences between my Tomcat 7 and 8 implementations that I completely overlooked the obvious answer. Good to have a 2nd set of eyes. Now I'm wondering why I don't get the same error on Tomcat 7 as it has the same config.xml, so it also has a bad validation query. Anyway, thanks for the help. Correcting my Oracle validation query resolved the issue.
     
    Roel De Nijs
    Sheriff
    Posts: 10662
    144
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Dean Thomsen wrote:and DOH! how did I miss that? I was so focused on trying to find differences between my Tomcat 7 and 8 implementations that I completely overlooked the obvious answer. Good to have a 2nd set of eyes.

    Yeah, sometimes a 2nd pair of eyes can be really enlightening (and most of the times result in a moment). Glad to hear your issue is solved!
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic