org.springframework.jdbc.CannotGetJdbcConnectionException - java

I am working in spring3 project. When I run my code sometimes i am getting this Jdbc Connection Exception for some particular functionality but other functionalities working very fine. And also this Exception is not occurring repetitively but sometimes, So I can't get where the mistake will be.
Please help me to come out of this problem.
<[weblogic.servlet.internal.WebAppServletContext#1b6e978 - appName: '_auto_generated_ear_', name: 'ae', context-path: '/ae'] Root cause of ServletException.
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
The Connection descriptor used by the client was:
localhost:1521:XE at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:573)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674)
Truncated. see log file for complete stacktrace
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12519, TNS:no appropriate service handler found
The Connection descriptor used by the client was:
localhost:1521:XE
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:261)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.(PhysicalConnection.java:420)
at oracle.jdbc.driver.T4CConnection.(T4CConnection.java:165)
Truncated. see log file for complete stacktrace

There are 2 common reason for that symptoms
The connection pool is exhausted, too many active connections open and the next client cannot get it. This might be a connection pool leak
The connection pool setting doesn't test idle connection periodically / on borrow, hence when TCP connection truncated by OS (eg: because the OS thinks it's idle doing nothing), the pool still thinks it's a valid

To resolve this issue, just Restart your MySQL service
How to restart the MySQL service
On Windows: https://www.mysqltutorial.org/mysql-adminsitration/restart-mysql
On Linux:    https://linuxhint.com/restart-mysql-in-ubuntu/

Related

Play framework java connection is not available to sql server database

I'm stucked in a problem during connection from my java project (play framework ) to a sql server database in Azure.
In local enviroment the connection works fine.
Below parameter in my application.conf :
db.default {
url="jdbc:sqlserver://server-name.database.windows.net:1433;database=database-name"
encrypt=true
trustServerCertificate=false
hostNameInCertificate="*.database.windows.net"
loginTimeout=30
driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
username="root"
password="RootPwd"
}
This is the error received:
ERROR o.h.e.jdbc.spi.SqlExceptionHelper HikariPool-1 - Connection is
not available, request timed out after 30006ms. ERROR
o.h.e.jdbc.spi.SqlExceptionHelper The TCP/IP connection to the host
par-sql-server.database.windows.net, port 1433 has failed. Error:
"par-sql-server.database.windows.net. Verify the connection
properties. Make sure that an instance of SQL Server is running on the
host and accepting TCP/IP connections at the port. Make sure that TCP
connections to the port are not blocked by a firewall.". ERROR
p.api.http.DefaultHttpErrorHandler
play.api.PlayException: Execution exception[[CompletionException:
org.hibernate.exception.JDBCConnectionException: Unable to acquire
JDBC Connection]]
at play.api.http.HttpErrorHandlerExceptions$.$anonfun$convertToPlayException$3(HttpErrorHandler.scala:388)
at scala.Option.getOrElse(Option.scala:201)
at play.api.http.HttpErrorHandlerExceptions$.convertToPlayException(HttpErrorHandler.scala:388)
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:373)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:264)
at play.core.server.AkkaHttp
I have already checked that tcp/ip port 1433 is correctly available for database, and my ip is correctly setted to avoid firewall.
Any suggestions?
thanks
Usually this error occurs when the database is not getting the connection within the default connectionTimeout property.
You can try to increase the value of connectionTimeout in Java config as below:
config.setConnectionTimeout(300000);
below is one of the sample config:
HikariConfig config = new HikariConfig();
config.setMaximumPoolSize(20);
config.setConnectionTimeout(300000);
config.setConnectionTimeout(120000);
config.setLeakDetectionThreshold(300000);
If possible let me know the steps to reproduce this issue so that I can fix it accordingly, also based on the information you've provided these blogs (Blog1, Blog2) will help you in establishing the connection

SQL Error: 17002, SQLState: 08006 IO Error: A connection attempt failed because the connected party did not properly respond after a period of time

I have an multithreaded spring application which interacts with database with a set of queries and gives the output. I recently encountered this error and not sure exactly what is its cause. As far as managing the connections on the server, I don't see any issues over there and till now everything was getting executed as expected and I haven't made any recent changes.
I see After some time things started working as expected, but now I'm curios about this error and the cause of it just to prevent this in future.
Posting the log trace as below, any help in decoding this will be highly appreciated.
SQL Error: 17002, SQLState: 08006
2021-03-11 13:46:28,508 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (default task-59) IO Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
2021-03-11 13:46:28,548 WARN [org.jboss.jca.adapters.jdbc.WrappedConnection] (default task-59) IJ030041: Error during closing a statement for: java:jboss/datasources/<pool-name>: java.sql.SQLRecoverableException: Closed Connection
at oracle.jdbc.driver.PhysicalConnection.needLine(PhysicalConnection.java:3247)
at oracle.jdbc.driver.OracleStatement.closeOrCache(OracleStatement.java:1392)
at oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:1375)
at oracle.jdbc.driver.OracleStatementWrapper.close(OracleStatementWrapper.java:119)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.close(OraclePreparedStatementWrapper.java:96)
at org.jboss.jca.adapters.jdbc.WrappedStatement.internalClose(WrappedStatement.java:1491)
at org.jboss.jca.adapters.jdbc.WrappedConnection.returnConnection(WrappedConnection.java:286)
at org.jboss.jca.adapters.jdbc.WrappedConnection.close(WrappedConnection.java:256)
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.closeConnection(DatasourceConnectionProviderImpl.java:144)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.releaseConnection(AbstractSessionImpl.java:391)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.releaseConnection(LogicalConnectionImpl.java:255)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.close(LogicalConnectionImpl.java:182)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:205)
at org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl.close(TransactionCoordinatorImpl.java:297)
at org.hibernate.internal.SessionImpl.close(SessionImpl.java:369)
Hibernate tries to close a statement but the connection (session) has been closed/terminated for some reason:
Error during closing a statement for:
java:jboss/datasources/: java.sql.SQLRecoverableException:
Closed Connection
SQL Error: 17002, SQLState: 08006 IO Error: A connection attempt
failed because the connected party did not properly respond after a
period of time, or established connection failed because connected
host has failed to respond
There could be multiple reason why this happen. Maybe it was a network problem that caused a timeout.
You should check with your DBA if he can see any errors on the database server.
Do you have configured database connection validation for your JDBC datasource?
http://www.mastertheboss.com/jboss-server/jboss-datasource/how-to-automatically-reconnect-to-the-database-in-wildfly
There was a network connection blip between your app server & database server. But what caused it, we can't explain without any more details. If it started working automatically, then it looks like a temporary network issue between the two servers. Or it would have caused if you have used invalid ip/dns name in db server url. But that would require a change from your side to fix the issue.

wso2 emm 500: Something has gone wrong

After general server configuration i'm able to log in to carbon, store or publisher without any issue with default admin login.
Unfortunately when i sign in EMM: https://myserver:port/emm -> sso/login
i end up in /emm/acs - "500: Something has gone wrong" page.
Debug: 2 errors in live terminal:
*[2015-06-12 20:35:21,254] ERROR {org.jaggeryjs.hostobjects.xhr.XMLHttpRequestHostObject} - Connection refused java.net.ConnectException: Connection refused*
*[2015-06-12 20:35:21,261] ERROR {org.jaggeryjs.jaggery.core.manager.WebAppManager} - org.mozilla.javascript.WrappedException: Wrapped org.jaggeryjs.scriptengine.exceptions.ScriptException: java.net.ConnectException: Connection refused (http#220)
org.jaggeryjs.scriptengine.exceptions.ScriptException: org.mozilla.javascript.WrappedException: Wrapped org.jaggeryjs.scriptengine.exceptions.ScriptException: java.net.ConnectException: Connection refused (http#220)*
And i got another 2 errors after wso2server startup:
*[2015-06-12 21:44:34,231] ERROR {org.wso2.carbon.apimgt.keymgt.internal.APIKeyMgtServiceComponent} - Error in initializing thrift transport
org.apache.thrift.transport.TTransportException: Could not bind to port 10397*
*[2015-06-12 21:44:34,247] ERROR {org.wso2.carbon.apimgt.keymgt.internal.APIKeyMgtServiceComponent} - Failed to initialize key management service.
java.lang.Exception: Error in initializing thrift transport*
Any hints?
Regards,
Lukas
I encountered with the /emm/acs redirection issue, actually I don't know why it has been happening, but when it happens, I do a refresh on the page, everything works fine.
The second issue you have mentioned, is nothing to do with the first one, it says that Apache Thrift Transport layer could not bind the port. Since EMM does not require Thrift, you can simply disable by editing the following XML configuration files.
Change true to false for the following config files, under the target folder.
./repository/conf/api-manager.xml:280: <EnableThriftServer>true</EnableThriftServer>
./repository/conf/identity.xml:218: <EnableThriftService>true</EnableThriftService>

SQL Nested Exception

I am facing this problem.
Stackstrace
2014-09-22 16:50:35,292 [main] WARN org.hibernate.cfg.SettingsFactory
- Could not obtain connection metadata org.apache.commons.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (IO Error: Connection reset) at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
can any one please let me know the cause of this , oracle version is 11g
Your stack trace specifies that you are unable to connect to your database.
Make sure that your database server is listening on the correct port (1521 default).
Check your firewall or any setting that prevents you from accessing your database server
Check your dataSource settings for any errors.
If your database is an external one, make sure that the listener.ora is configured correctly.

RabbitMQ consumer losing connection

We are using RabbitMQ 3.3.1, spring-amqp-1.3.1, spring-rabbit-1.3.1 in our project and we are getting following exception. Our environment is in Azure cloud and we are seeing that the RabbitMQ server is losing the connection with the consumers more often. Once we restart our OSGI consumer bundle, it works for some time and then same issue occurs. Any help/tips are appreciated.
[SimpleAsyncTaskExecutor2]|WARN|org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer|370-spring-rabbit-1.3.1.RELEASE|Consumer
raised exception, processing can restart if the connection factory
supports it com.rabbitmq.client.ShutdownSignalException: connection
error; reason: java.net.SocketException: Connection reset at
com.rabbitmq.client.impl.AMQConnection.startShutdown(AMQConnection.java:715)[367:com.rabbitmq.client:3.2.4]
at
com.rabbitmq.client.impl.AMQConnection.shutdown(AMQConnection.java:705)[367:com.rabbitmq.client:3.2.4]
at
com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:568)[367:com.rabbitmq.client:3.2.4]
Caused by: java.net.SocketException: Connection reset at
java.net.SocketInputStream.read(SocketInputStream.java:196)[:1.7.0_51]
at
java.net.SocketInputStream.read(SocketInputStream.java:122)[:1.7.0_51]
at
sun.security.ssl.InputRecord.readFully(InputRecord.java:442)[:1.7.0_51]
at sun.security.ssl.InputRecord.read(InputRecord.java:480)[:1.7.0_51]
at
sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:927)[:1.7.0_51]
at
sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884)[:1.7.0_51]
at
sun.security.ssl.AppInputStream.read(AppInputStream.java:102)[:1.7.0_51]
at
java.io.BufferedInputStream.fill(BufferedInputStream.java:235)[:1.7.0_51]
at
java.io.BufferedInputStream.read(BufferedInputStream.java:254)[:1.7.0_51]
at
java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288)[:1.7.0_51]
at
com.rabbitmq.client.impl.Frame.readFrom(Frame.java:95)[367:com.rabbitmq.client:3.2.4]
at
com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:131[367:com.rabbitmq.client:3.2.4]
at
com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:533[367:com.rabbitmq.client:3.2.4]

Categories