I using springboot with HikariCP, but after a while my app crash and I got the error:
org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
...
Caused by: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
....
Caused by: java.sql.SQLTransientConnectionException: HikariPool-6 - Connection is not available, request timed out after 30000ms.
This is my aplication.properties
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.url=jdbc:postgresql://localhost:5432/db_dnaso
#spring.datasource.url=jdbc:postgresql://172.16.1.10:5432/db_dnaso
spring.datasource.username=postgres
spring.datasource.password=dna44100
spring.datasource.driver-class-name=org.postgresql.Driver
So I have a lot of save, find and anothers access to DB, how can I visualize how method are blocking my connection?
tks
It looks like your your database server is running out of connection. Default value for property maximumPoolSize in Hikari is 10. That means it will try to create 10 connection on server startup and it will not start if not able to acquire 10 connection or may fail if your db server pool size having less connection in the pool as you are creating using Hikari configuration.
If you are able to start Spring Boot server and then facing this issue then try enabling leakDetectionThreshold and check which connection is taking more time and not returning to Hikari pool .
spring:
datasource:
hikari:
leak-detection-threshold: 2000
Enable the leakDetectionThreshold, set to something like 1 minute (60000ms). It is likely that you have a connection leak somewhere ... a connection is borrowed but never closed (returned).
In springboot, you can set spring.datasource.hikari.leak-detection-threshold=10000 (in milliseconds) in application.properties.
And the default value for maximumPoolSize is 10. You can change it with spring.datasource.hikari.maximum-pool-size=xx.
Related
I have checked that all relevant parameters are being parsed correctly and i am able to see them in my AWS ECS service. When the service is spun up i get the below error WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (ServerService Thread Pool -- 60) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: IJ031084: Unable to create connection which then follows with this error Caused by: org.postgresql.util.PSQLException: FATAL: database "keycloak" does not exist
I am unsure if the two are related. I validated relevant parameters and have tried to imitate the same issue locally.
Any help or advice would be aprpeciated
TYIA
Why JBOSS ORACLE datasource doesn't fail fast when query times out?
Environment: jboss-eap-7.0
I was waiting a fast fail with the exception:
java.sql.SQLTimeoutException: ORA-01013 user requested cancel of current operation
But I get the following after the end of transaction.
Caused by: java.lang.Throwable: setRollbackOnly called from:
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.setRollbackOnly(TransactionImple.java:339)
How do I force it to fail fast?
This is related to the JDBC driver version and firewall stuff.
This is not related to JBOSS, XA, JTA, DATASOURCE or something else.
See: https://www.ibm.com/mysupport/s/question/0D50z000062kF2p/why-is-the-webspheredefaultquerytimeout-property-for-timing-out-sql-queries-not-working
Trying to connect to cosmosdb Mongo API using Primary Connection String and UserName(Database Name)
Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1#3c291aad. Client view of cluster state is {type=REPLICA_SET, servers=[{address=**********.documents.azure.com:10255, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketWriteException: Exception sending message}, caused by {java.net.SocketException: Connection reset}}]
at com.mongodb.internal.connection.BaseCluster.createTimeoutException(BaseCluster.java:401) ~[mongodb-driver-core-3.8.2.jar:na]
at com.mongodb.internal.connection.BaseCluster.selectServer(BaseCluster.java:120) ~[mongodb-driver-core-3.8.2.jar:na]
at com.mongodb.internal.connection.MultiServerCluster.selectServer(MultiServerCluster.java:54) ~[mongodb-driver-core-3.8.2.jar:na]
at com.mongodb.client.internal.MongoClientDelegate.getConnectedClusterDescription(MongoClientDelegate.java:138) ~[mongodb-driver-3.8.2.jar:na]
at com.mongodb.client.internal.MongoClientDelegate.createClientSession(MongoClientDelegate.java:94) ~[mongodb-driver-3.8.2.jar:na]
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.getClientSession(MongoClientDelegate.java:249) ~[mongodb-driver-3.8.2.jar:na]
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:190) ~[mongodb-driver-3.8.2.jar:na]
at com.mongodb.client.internal.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:960) ~[mongodb-driver-3.8.2.jar:na]
at com.mongodb.client.internal.MongoCollectionImpl.executeDelete(MongoCollectionImpl.java:940) ~[mongodb-driver-3.8.2.jar:na]
at com.mongodb.client.internal.MongoCollectionImpl.deleteMany(MongoCollectionImpl.java:551) ~[mongodb-driver-3.8.2.jar:na]
at org.springframework.data.mongodb.core.MongoTemplate$9.doInCollection(MongoTemplate.java:1729) ~[spring-data-mongodb-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.data.mongodb.core.MongoTemplate$9.doInCollection(MongoTemplate.java:1689) ~[spring-data-mongodb-2.1.9.RELEASE.jar:2.1.9.RELEASE]
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:545) ~[spring-data-mongodb-2.1.9.RELEASE.jar:2.1.9.RELEASE]
... 30 common frames omitted
Please follow the example github project in the link below and you will be able to connect.
https://github.com/Azure-Samples/azure-cosmos-db-mongodb-spring
Try with MongoDB driver 3.7.1 or earlier.
It appears that’s there’s an issue with MongoDB driver for Java 3.8.0 and above and the way Cosmos DB takes the MongoDB protocol.
I have built alfresco(version 5.2) from source on ubuntu 16.04. I want to deploy alfresco on tomcat 8. The deployment is successful however the PostgreSQL database is not getting configured as required. I have followed the steps as given in http://docs.alfresco.com/5.1/tasks/postgresql-config.html
I observe the home page as given in image alfresco_page
Am I missing onto something here that the PostgreSQL database is not getting configured. Is there any other configuration that needs to be done that I have missed ?
UPDATE
The alfresco.log gave me this
2017-08-01 05:53:54,406 WARN [org.alfresco.web.scripts.servlet.X509ServletFilterBase] [localhost-startStop-1] clientAuth does not appear to be set for Tomcat. clientAuth must be set to 'want' for X509 Authentication
2017-08-01 05:53:54,416 WARN [org.alfresco.web.scripts.servlet.X509ServletFilterBase] [localhost-startStop-1] Attempting to set clientAuth=want through JMX...
2017-08-01 05:53:54,427 WARN [org.alfresco.web.scripts.servlet.X509ServletFilterBase] [localhost-startStop-1] Unable to set clientAuth=want through JMX.
2017-08-01 05:53:55,139 ERROR [org.apache.solr.core.CoreContainer] [coreLoadExecutor-5-thread-1] Error creating core [collection1]: Could not load conf for core collection1: Error loading solr config from solr/collection1/conf/solrconfig.xml
org.apache.solr.common.SolrException: Could not load conf for core collection1: Error loading solr config from solr/collection1/conf/solrconfig.xml
at org.apache.solr.core.ConfigSetService.getConfig(ConfigSetService.java:66)
at org.apache.solr.core.CoreContainer.create(CoreContainer.java:489)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:255)
at org.apache.solr.core.CoreContainer$1.call(CoreContainer.java:249)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.solr.common.SolrException: Error loading solr config from solr/collection1/conf/solrconfig.xml
at org.apache.solr.core.SolrConfig.readFromResourceLoader(SolrConfig.java:154)
at org.apache.solr.core.ConfigSetService.createSolrConfig(ConfigSetService.java:80)
at org.apache.solr.core.ConfigSetService.getConfig(ConfigSetService.java:61)
... 7 more
Caused by: java.io.IOException: Can't find resource 'solrconfig.xml' in classpath or '/root/tomcat85/output/build/webapps/solr/collection1/conf'
at org.apache.solr.core.SolrResourceLoader.openResource(SolrResourceLoader.java:362)
at org.apache.solr.core.SolrResourceLoader.openConfig(SolrResourceLoader.java:308)
at org.apache.solr.core.Config.<init>(Config.java:117)
at org.apache.solr.core.Config.<init>(Config.java:87)
at org.apache.solr.core.SolrConfig.<init>(SolrConfig.java:167)
at org.apache.solr.core.SolrConfig.readFromResourceLoader(SolrConfig.java:145)
... 9 more
2017-08-01 05:54:09,634 WARN [org.hibernate.cfg.SettingsFactory] [localhost-startStop-1] Could not obtain connection metadata
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:83)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2079)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1304)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:863)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:782)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:188)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1573)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1511)
Things to check:
Is postgres running (ps -ef|grep postgres)?
Can you use psql to connect to postgres using the db.name, db.username, and db.password that are configured in alfresco-global.properties?
Did you follow the step in the docs about editing pg_hba.conf to make sure that postgres is configured to allow password based authentication?
Also, it is exceedingly rare to need to build Alfresco from source unless you are making changes to the low-level classes themselves, which is not recommended.
I have a simple application that uses hibernate to work with db. When i check connection and some methods in main method, everything is fine. But when i deploy it on server, it throws
javax.servlet.ServletException: Cant instantiate class: managed.ClientsBean.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
root cause:
com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class: managed.ClientsBean.
...
root cause:
javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Could not open connection
...
root cause:
org.hibernate.exception.JDBCConnectionException: Could not open connection
root cause
java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/project
But I have that driver, in jboss\standalone\deployments too. How can I make jboss see it?
See here:
https://community.jboss.org/wiki/DataSourceConfigurationInAS7
And here
JDBC Postgresql driver on JBoss 7