"HikariPool-1 - Connection is not available, request timed out after 30004ms." exception occurs only on the development server - spring-boot

"Hikari Pool-1 - Connection is not available, request timed out after 30004ms." exception occurs only on the development server.
I spent a lot of time trying to find this problem, but I couldn't. For the first time in my life, I'm posting a question on stackoverflow.Please let me know if there is anything lacking in the question.
For your understanding, I have placed an example source code on GitHub.
I included the DDL Query used in the example below the resource folder and the log file (dev-log.out) on the actual development server.
I wrote down what I wanted to ask you at the bottom.
The requirements I am trying to implement are as follows.
Put the data from the source table into the target table.
If an exception occurs in the process of 1), the transaction is rolled back and the corresponding exception information is loaded on the log table.
To meet this requirement, I declared #Transactional to a service class (DemoService class in the example) that performs 1).
#RequiredArgsConstructor
#Service
public class DemoService {
private final DemoRepository repository;
#Transactional
#Logging
public void run() {
List<Integer> ids = repository.select(); //select from source table
for (Integer id : ids) {
repository.insert(id); //insert into target table
//An exception was made intentionally to roll back test
if (id == 1) {
throw new RuntimeException("exception~~");
}
}
}
}
And I wrote Aop using #Aspect (LoggingAspect in the example) to load exception information into the table. And I gave the REQUIRES_NEW option because the transaction loading exception information should be committed separately from the transaction used in 1).
#RequiredArgsConstructor
#Slf4j
#Component
#Aspect
public class LoggingAspect {
private final LoggingService loggingService;
#AfterThrowing(value = "#annotation(com.example.dbcpquestion.logging.Logging)", throwing = "ex")
public void doLog(JoinPoint joinPoint, Exception ex) throws Throwable {
log.error("-----------------------------------------");
int cnt = loggingService.logging();
log.error("cnt={}", cnt);
log.error("-----------------------------------------");
}
}
#RequiredArgsConstructor
#Service
public class LoggingService {
private final LoggingRepository repository;
#Transactional(propagation = Propagation.REQUIRES_NEW)
public int logging() {
return repository.save(); //insert exception info into log table
}
}
I know that if an exception occurs while performing 1) logic, at least two connections are required. (Transactions that work to move data from the Source table to the Target table that will eventually be rolled back, and transactions that load exception information into the log table)
The problem is!
The logic (1, 2) above works fine on the local PC, but when deployed to the development server, the exception "Hikari Pool-1 - Connection is not available, request timed out after 30004ms."
The strangest thing happens intermittently... (crazy)
Here's the Hikari setup log.
[2022-10-06 18:46:00.724] [DEBUG] [main] [HikariConfig ]- HikariPool-1 - configuration:
[2022-10-06 18:46:00.730] [DEBUG] [main] [HikariConfig ]- allowPoolSuspension................................false
[2022-10-06 18:46:00.730] [DEBUG] [main] [HikariConfig ]- autoCommit................................true
[2022-10-06 18:46:00.730] [DEBUG] [main] [HikariConfig ]- catalog................................none
[2022-10-06 18:46:00.730] [DEBUG] [main] [HikariConfig ]- connectionInitSql................................none
[2022-10-06 18:46:00.731] [DEBUG] [main] [HikariConfig ]- connectionTestQuery................................none
[2022-10-06 18:46:00.731] [DEBUG] [main] [HikariConfig ]- connectionTimeout................................30000
[2022-10-06 18:46:00.731] [DEBUG] [main] [HikariConfig ]- dataSource................................none
[2022-10-06 18:46:00.732] [DEBUG] [main] [HikariConfig ]- dataSourceClassName................................none
[2022-10-06 18:46:00.732] [DEBUG] [main] [HikariConfig ]- dataSourceJNDI................................none
[2022-10-06 18:46:00.734] [DEBUG] [main] [HikariConfig ]- dataSourceProperties................................{password=<masked>}
[2022-10-06 18:46:00.734] [DEBUG] [main] [HikariConfig ]- driverClassName................................"oracle.jdbc.OracleDriver"
[2022-10-06 18:46:00.734] [DEBUG] [main] [HikariConfig ]- exceptionOverrideClassName................................none
[2022-10-06 18:46:00.734] [DEBUG] [main] [HikariConfig ]- healthCheckProperties................................{}
[2022-10-06 18:46:00.734] [DEBUG] [main] [HikariConfig ]- healthCheckRegistry................................none
[2022-10-06 18:46:00.735] [DEBUG] [main] [HikariConfig ]- idleTimeout................................600000
[2022-10-06 18:46:00.735] [DEBUG] [main] [HikariConfig ]- initializationFailTimeout................................1
[2022-10-06 18:46:00.735] [DEBUG] [main] [HikariConfig ]- isolateInternalQueries................................false
[2022-10-06 18:46:00.735] [DEBUG] [main] [HikariConfig ]- jdbcUrl................................[Cleared for security reasons.]
[2022-10-06 18:46:00.736] [DEBUG] [main] [HikariConfig ]- keepaliveTime................................0
[2022-10-06 18:46:00.736] [DEBUG] [main] [HikariConfig ]- leakDetectionThreshold................................2000
[2022-10-06 18:46:00.736] [DEBUG] [main] [HikariConfig ]- maxLifetime................................1800000
[2022-10-06 18:46:00.736] [DEBUG] [main] [HikariConfig ]- maximumPoolSize................................3
[2022-10-06 18:46:00.737] [DEBUG] [main] [HikariConfig ]- metricRegistry................................none
[2022-10-06 18:46:00.737] [DEBUG] [main] [HikariConfig ]- metricsTrackerFactory................................none
[2022-10-06 18:46:00.737] [DEBUG] [main] [HikariConfig ]- minimumIdle................................3
[2022-10-06 18:46:00.737] [DEBUG] [main] [HikariConfig ]- password................................<masked>
[2022-10-06 18:46:00.737] [DEBUG] [main] [HikariConfig ]- poolName................................"HikariPool-1"
[2022-10-06 18:46:00.738] [DEBUG] [main] [HikariConfig ]- readOnly................................false
[2022-10-06 18:46:00.738] [DEBUG] [main] [HikariConfig ]- registerMbeans................................false
[2022-10-06 18:46:00.738] [DEBUG] [main] [HikariConfig ]- scheduledExecutor................................none
[2022-10-06 18:46:00.738] [DEBUG] [main] [HikariConfig ]- schema................................none
[2022-10-06 18:46:00.739] [DEBUG] [main] [HikariConfig ]- threadFactory................................internal
[2022-10-06 18:46:00.739] [DEBUG] [main] [HikariConfig ]- transactionIsolation................................default
[2022-10-06 18:46:00.739] [DEBUG] [main] [HikariConfig ]- username................................[Cleared for security reasons.]
[2022-10-06 18:46:00.739] [DEBUG] [main] [HikariConfig ]- validationTimeout................................5000
[2022-10-06 18:46:00.739] [INFO ] [main] [HikariDataSource ]- HikariPool-1 - Starting...
[2022-10-06 18:46:02.249] [DEBUG] [main] [HikariPool ]- HikariPool-1 - Added connection oracle.jdbc.driver.T4CConnection#1fc684e
[2022-10-06 18:46:02.252] [INFO ] [main] [HikariDataSource ]- HikariPool-1 - Start completed.
[2022-10-06 18:46:02.288] [INFO ] [main] [DemoService ]- [select]..................
[2022-10-06 18:46:02.361] [DEBUG] [HikariPool-1 housekeeper] [HikariPool ]- HikariPool-1 - Pool stats (total=1, active=1, idle=0, waiting=0)
[2022-10-06 18:46:02.369] [DEBUG] [HikariPool-1 connection adder] [PoolBase ]- HikariPool-1 - Failed to create/setup connection: null
[2022-10-06 18:46:02.390] [DEBUG] [HikariPool-1 connection adder] [HikariPool ]- HikariPool-1 - Cannot acquire connection from data source
java.lang.NullPointerException: null
Yaml file settings.
Logging level has been set to DEBUG.
Hikari's maximum-pool-size is set to 3. As far as I know, I can set it to 2, but...I added one more connection
I also set leak-detection-threshold to look at connection leak.
As an example, url was specified as localhost, but the URL is actually specified as an IP address, not localhost. Both local profiles and dev profiles have the same DB connection information.
spring:
datasource:
username: dbcp
password: dbcp
driver-class-name: oracle.jdbc.OracleDriver
hikari:
maximum-pool-size: 3
leak-detection-threshold: 2000
logging:
pattern:
console: "[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%thread] [%-25logger{0}]- %msg%n"
level:
'[com.zaxxer.hikari]': trace
'[com.zaxxer.hikari.HikariConfig]': debug
---
spring:
config:
activate:
on-profile: local
datasource:
url: jdbc:oracle:thin:#localhost:1521:orcl
#As an example, url was specified as localhost, but the URL is actually specified as an IP address, not localhost. Both local profiles and dev profiles have the same DB connection information.
---
spring:
config:
activate:
on-profile: dev
datasource:
url: jdbc:oracle:thin:#localhost:1521:orcl
The entire log.(Omit part of the log because of the number of characters.)
[2022-10-06 18:46:02.361] [DEBUG] [HikariPool-1 housekeeper] [HikariPool ]- HikariPool-1 - Pool stats (total=1, active=1, idle=0, waiting=0)
[2022-10-06 18:46:02.369] [DEBUG] [HikariPool-1 connection adder] [PoolBase ]- HikariPool-1 - Failed to create/setup connection: null
[2022-10-06 18:46:02.390] [DEBUG] [HikariPool-1 connection adder] [HikariPool ]- HikariPool-1 - Cannot acquire connection from data source
java.lang.NullPointerException: null
at java.base/java.lang.StringCoding.encode(StringCoding.java:652)
at java.base/java.lang.String.getBytes(String.java:982)
at java.base/java.lang.ProcessEnvironment$Variable.valueOfQueryOnly(ProcessEnvironment.java:166)
at java.base/java.lang.ProcessEnvironment$Variable.valueOfQueryOnly(ProcessEnvironment.java:162)
at java.base/java.lang.ProcessEnvironment$StringEnvironment.get(ProcessEnvironment.java:239)
at java.base/java.lang.ProcessEnvironment$StringEnvironment.get(ProcessEnvironment.java:221)
at java.base/java.util.Collections$UnmodifiableMap.get(Collections.java:1454)
at java.base/java.lang.ProcessEnvironment.getenv(ProcessEnvironment.java:85)
at java.base/java.lang.System.getenv(System.java:1001)
at oracle.jdbc.driver.PhysicalConnection.lambda$getTnsAdminFromEnv$4(PhysicalConnection.java:10990)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at oracle.jdbc.driver.PhysicalConnection.getTnsAdminFromEnv(PhysicalConnection.java:10987)
at oracle.jdbc.driver.PhysicalConnection.readConnectionProperties(PhysicalConnection.java:1427)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:941)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:926)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:542)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:69)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:728)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:649)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476)
at com.zaxxer.hikari.pool.HikariPool.access$100(HikariPool.java:71)
at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:726)
at com.zaxxer.hikari.pool.HikariPool$PoolEntryCreator.call(HikariPool.java:712)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
[2022-10-06 18:46:02.660] [DEBUG] [HikariPool-1 connection adder] [HikariPool ]- HikariPool-1 - Cannot acquire connection from data source
java.lang.NullPointerException: null
at java.base/java.lang.StringCoding.encode(StringCoding.java:652)
at java.base/java.lang.String.getBytes(String.java:982)
at java.base/java.lang.ProcessEnvironment$Variable.valueOfQueryOnly(ProcessEnvironment.java:166)
at java.base/java.lang.ProcessEnvironment$Variable.valueOfQueryOnly(ProcessEnvironment.java:162)
at java.base/java.lang.ProcessEnvironment$StringEnvironment.get(ProcessEnvironment.java:239)
/////Omit part of the log because of the number of characters.
[2022-10-06 18:46:02.928] [ERROR] [main] [LoggingAspect ]- -----------------------------------------
[2022-10-06 18:46:03.055] [DEBUG] [HikariPool-1 connection adder] [HikariPool ]- HikariPool-1 - Cannot acquire connection from data source
java.lang.NullPointerException: null
at java.base/java.lang.StringCoding.encode(StringCoding.java:652)
/////Omit part of the log because of the number of characters.
[2022-10-06 18:46:03.624] [DEBUG] [HikariPool-1 connection adder] [HikariPool ]- HikariPool-1 - Cannot acquire connection from data source
java.lang.NullPointerException: null
at java.base/java.lang.StringCoding.encode(StringCoding.java:652)
/////Omit part of the log because of the number of characters.
[2022-10-06 18:46:04.278] [WARN ] [HikariPool-1 housekeeper] [ProxyLeakTask ]- Connection leak detection triggered for oracle.jdbc.driver.T4CConnection#1fc684e on thread main, stack trace follows
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:265)
/////Omit part of the log because of the number of characters.
[2022-10-06 18:46:04.475] [DEBUG] [HikariPool-1 connection adder] [HikariPool ]- HikariPool-1 - Cannot acquire connection from data source
java.lang.NullPointerException: null
at java.base/java.lang.StringCoding.encode(StringCoding.java:652)
/////Omit part of the log because of the number of characters.
[2022-10-06 18:46:05.745] [DEBUG] [HikariPool-1 connection adder] [HikariPool ]- HikariPool-1 - Cannot acquire connection from data source
java.lang.NullPointerException: null
at java.base/java.lang.StringCoding.encode(StringCoding.java:652)
[2022-10-06 18:46:32.371] [DEBUG] [HikariPool-1 housekeeper] [HikariPool ]- HikariPool-1 - Pool stats (total=1, active=1, idle=0, waiting=1)
[2022-10-06 18:46:32.371] [DEBUG] [HikariPool-1 housekeeper] [HikariPool ]- HikariPool-1 - Fill pool skipped, pool is at sufficient level.
[2022-10-06 18:46:32.931] [DEBUG] [main] [HikariPool ]- HikariPool-1 - Timeout failure stats (total=1, active=1, idle=0, waiting=0)
[2022-10-06 18:46:32.955] [INFO ] [main] [ProxyLeakTask ]- Previously reported leaked connection oracle.jdbc.driver.T4CConnection#1fc684e on thread main was returned to the pool (unleaked)
[2022-10-06 18:46:32.961] [INFO ] [main] [ConditionEvaluationReportLoggingListener]-
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2022-10-06 18:46:33.010] [ERROR] [main] [SpringApplication ]- Application run failed
java.lang.IllegalStateException: Failed to execute ApplicationRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:763)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
at com.springboot.example.ExampleApplication.main(ExampleApplication.java:19)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30004ms.
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:309)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.startTransaction(AbstractPlatformTransactionManager.java:400)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.handleExistingTransaction(AbstractPlatformTransactionManager.java:434)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:352)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:595)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:382)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at com.springboot.example.logging.LoggingService$$EnhancerBySpringCGLIB$$f2e4eeed.logging(<generated>)
at com.springboot.example.logging.LoggingAspect.doLog(LoggingAspect.java:23)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:617)
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:68)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at com.springboot.example.DemoService$$EnhancerBySpringCGLIB$$3b65fd43.run(<generated>)
at com.springboot.example.ExampleApplication.lambda$applicationRunner$0(ExampleApplication.java:27)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:773)
... 13 common frames omitted
Caused by: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30004ms.
at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:696)
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:197)
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:162)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:265)
... 45 common frames omitted
[2022-10-06 18:46:33.020] [INFO ] [main] [HikariDataSource ]- HikariPool-1 - Shutdown initiated...
[2022-10-06 18:46:33.020] [DEBUG] [main] [HikariPool ]- HikariPool-1 - Before shutdown stats (total=1, active=0, idle=1, waiting=0)
[2022-10-06 18:46:33.023] [DEBUG] [HikariPool-1 connection closer] [PoolBase ]- HikariPool-1 - Closing connection oracle.jdbc.driver.T4CConnection#1fc684e: (connection evicted)
[2022-10-06 18:46:40.826] [DEBUG] [main] [HikariPool ]- HikariPool-1 - After shutdown stats (total=0, active=0, idle=0, waiting=0)
[2022-10-06 18:46:40.826] [INFO ] [main] [HikariDataSource ]- HikariPool-1 - Shutdown completed.
What I checked to solve this problem is as follows.
I checked the settings of the Oracle DB server.
'IDLE_TIME' is set much longer than Hikari maxLifeTime.
'CONNECT_TIME' is unlimit.
We excluded the setting to load all spring bean into Lazy.
The actual project uses Mybatis, but if you look at what happens when you use JdbcTemplate, as in the example...I don't think Mybatis or Lazy loading is the cause.
The local DB and the DB used by the development server are all the same.
I confirmed that there were three sessions connected from Oracle when the problem did not occur and that there was one session connected when the exception occurred. From this, I expected that the connection itself would not be obtained.
What I'm curious about is as follows.
When logging level is set to DEBUG, the message 'Hikari Pool-1 - Canot acquisition connection from data source' appears frequently. Is it related to this part? (And what does this message mean?) Is the network unstable?)
If you look at the entire log,
[2022-10-06 18:46:32.371] [DEBUG] [HikariPool-1 housekeeper] [HikariPool ]- HikariPool-1 - Pool stats (total=1, active=1, idle=0, waiting=1)
[2022-10-06 18:46:32.371] [DEBUG] [HikariPool-1 housekeeper] [HikariPool ]- HikariPool-1 - Fill pool skipped, pool is at sufficient level.
[2022-10-06 18:46:32.931] [DEBUG] [main] [HikariPool ]- HikariPool-1 - Timeout failure stats (total=1, active=1, idle=0, waiting=0)
~~~~
Caused by: org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30004ms.
This log remains. Can I say that it was 'waiting=1' and then changed to 'waiting=0' because a timeout exception occurred...?
Is it because you didn't get the connection?
Can't I run the application after the connection pool has three connections set to maximum-pool-size? As far as I know, Hikari's separate threads are out of control because they serve to get Connection.
I'd really appreciate your help.

Related

HikariPool-1 - Connection is not available, request timed out after 30050ms

I am using Oracle DB with spring-boot(2.6.2), upon running batch services, I am getting the following error:
*
36mo.h.engine.jdbc.spi.SqlExceptionHelper SQL Error: 0, SQLState: null
31mERROR 36mo.h.engine.jdbc.spi.SqlExceptionHelper: HikariPool-1 - Connection is not available, request timed out after 30050ms.
32mDEBUG 36mcom.zaxxer.hikari.pool.HikariPool: HikariPool-2 - Pool stats (total=10, active=0, idle=10, waiting=0)
32mDEBUG 36mcom.zaxxer.hikari.pool.: HikariPool-2 - Fill pool skipped, pool is at sufficient level.
32mDEBUG 36mcom.zaxxer.hikari.pool.HikariPool: HikariPool-1 - Pool stats (total=10, active=10, idle=0, waiting=1)
32mDEBUG 36mcom.zaxxer.hikari.pool.: HikariPool-1 - Fill pool skipped, pool is at sufficient level.
32mDEBUG 36mcom.zaxxer.hikari.pool.HikariPool: HikariPool-1 - Timeout failure stats (total=10, active=10, idle=0, waiting=0)
33m WARN 36mo.h.engine.jdbc.spi.SqlExceptionHelper: SQL Error: 0, SQLState: null
31mERROR 36mo.h.engine.jdbc.spi.SqlExceptionHelper: HikariPool-1 - Connection is not available, request timed out after 30002ms.
32mDEBUG 36mcom.zaxxer.hikari.pool.HikariPool: HikariPool-2 - Pool stats (total=10, active=0, idle=10, waiting=0)
32mDEBUG 36mcom.zaxxer.hikari.pool.: HikariPool-2 - Fill pool skipped, pool is at sufficient level.
32mDEBUG 36mcom.zaxxer.hikari.pool.HikariPool: HikariPool-1 - Pool stats (total=10, active=10, idle=0, waiting=1)
32mDEBUG 36mcom.zaxxer.hikari.pool.HikariPool: HikariPool-1 - Fill pool skipped, pool is at sufficient level.
32mDEBUG 36mcom.zaxxer.hikari.pool.HikariPool: HikariPool-1 - Timeout failure stats (total=10, active=10, idle=0, waiting=0)
33m WARN 36mo.h.engine.jdbc.spi.SqlExceptionHelper SQL Error: 0, SQLState: null
*
I see sometime the total connection becomes 0 and then it reaches 10 and then again back to 0. I went through websites for this error where they mentioned error related DataSource object. Below is the details of the properties file:
spring:
datasource:
ss:
driver-class-name: oracle.jdbc.driver.OracleDriver
hikari:
connection-timeout: 5000
maximum-pool-size: 10
idle-timeout: 60000
max-lifetime: 1800000
minimum-idle: 2
jdbc-url: ------URL---
Here is the configuration class function:
#Bean
#ConfigurationProperties(prefix="spring.datasource.ss")
public DataSource sourceDataSource() {
return DataSourceBuilder.create().build();
}
// EntityManager bean
#Bean
public LocalContainerEntityManagerFactoryBean sourceEntityManager() {
LocalContainerEntityManagerFactoryBean em
= new LocalContainerEntityManagerFactoryBean();
em.setDataSource(sourceDataSource());
........... .
I tried solving this...but didn't got concrete solution. So how to remove this error ?

Apache Camel: Help in understanding usage of SimpleScheduledRoutePolicy

Anybody has experience or know how to use SimpleScheduledRoutePolicy to manage a scheduler at runtime? To change the scheduler timing, suspend or resume. I tried using this in a spring boot project but it is not working as documented. Below is my Route configuration and a Test class I used to test this.
#Component
public class MyRouter extends RouteBuilder {
private static final Logger logger = LoggerFactory.getLogger(MyRouter.class);
#Override
public void configure() throws Exception {
SimpleScheduledRoutePolicy simpleScheduledRoutePolicy = new SimpleScheduledRoutePolicy();
long startTime = System.currentTimeMillis() + 5000l;
simpleScheduledRoutePolicy.setRouteStartDate(new Date(startTime));
simpleScheduledRoutePolicy.setRouteStartRepeatInterval(3000l);
simpleScheduledRoutePolicy.setRouteStartRepeatCount(3);
from("direct:myroute")
.routeId("myroute")
.routePolicy(simpleScheduledRoutePolicy)
.autoStartup(true)
.log(LoggingLevel.INFO, logger, "myroute invoked")
.to("mock:test");
}
}
Test class code
#RunWith(CamelSpringBootRunner.class)
#SpringBootTest
public class MyRouterTest {
#Autowired
private CamelContext camelContext;
#EndpointInject("mock:test")
MockEndpoint resultEndpoint;
#SneakyThrows
#Test
public void myRouteIsScheduledSuccessfully() {
resultEndpoint.expectedMessageCount(2);
Thread.sleep(7000);
resultEndpoint.assertIsSatisfied();
}
}
But I just gets below logs saying the scheduler started but it is not triggering every 3 seconds as configured in policy.
I tried to invoke the direct component from test method, still not working. Not sure where I am going wrong.
[INFO ] 2020-04-17 15:22:17.928 [main] MyRouterTest - Starting MyRouterTest on PPC11549 with PID 20892 (started by rmr in C:\Data\Telenet\Workspaces\atoms-event-engine)
[DEBUG] 2020-04-17 15:22:17.930 [main] MyRouterTest - Running with Spring Boot v2.2.6.RELEASE, Spring v5.2.5.RELEASE
[INFO ] 2020-04-17 15:22:17.932 [main] MyRouterTest - No active profile set, falling back to default profiles: default
[INFO ] 2020-04-17 15:22:19.634 [main] RepositoryConfigurationDelegate - Bootstrapping Spring Data JDBC repositories in DEFAULT mode.
[INFO ] 2020-04-17 15:22:19.679 [main] RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 36ms. Found 0 JDBC repository interfaces.
[INFO ] 2020-04-17 15:22:20.226 [main] PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'org.apache.camel.spring.boot.CamelAutoConfiguration' of type [org.apache.camel.spring.boot.CamelAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[INFO ] 2020-04-17 15:22:20.848 [main] HikariDataSource - HikariPool-1 - Starting...
[INFO ] 2020-04-17 15:22:21.437 [main] HikariDataSource - HikariPool-1 - Start completed.
[INFO ] 2020-04-17 15:22:22.602 [main] LRUCacheFactory - Detected and using LURCacheFactory: camel-caffeine-lrucache
[INFO ] 2020-04-17 15:22:24.082 [main] JobRepositoryFactoryBean - No database type set, using meta data indicating: H2
[INFO ] 2020-04-17 15:22:24.120 [main] SimpleJobLauncher - No TaskExecutor has been set, defaulting to synchronous executor.
[INFO ] 2020-04-17 15:22:24.485 [main] ThreadPoolTaskScheduler - Initializing ExecutorService 'taskScheduler'
[INFO ] 2020-04-17 15:22:24.695 [main] SpringBootRoutesCollector - Loading additional Camel XML routes from: classpath:camel/*.xml
[INFO ] 2020-04-17 15:22:24.698 [main] SpringBootRoutesCollector - Loading additional Camel XML rests from: classpath:camel-rest/*.xml
[INFO ] 2020-04-17 15:22:24.727 [main] MyRouterTest - Started MyRouterTest in 7.338 seconds (JVM running for 11.356)
[INFO ] 2020-04-17 15:22:24.729 [main] JobLauncherCommandLineRunner - Running default command line with: []
[INFO ] 2020-04-17 15:22:24.734 [main] CamelAnnotationsHandler - Setting shutdown timeout to [10 SECONDS] on CamelContext with name [camelContext].
[INFO ] 2020-04-17 15:22:24.815 [main] CamelSpringBootExecutionListener - #RunWith(CamelSpringBootRunner.class) before: class com.telenet.atoms.eventengine.camel.MyRouterTest.myRouteIsScheduledSuccessfully
[INFO ] 2020-04-17 15:22:24.817 [main] CamelSpringBootExecutionListener - Initialized CamelSpringBootRunner now ready to start CamelContext
[INFO ] 2020-04-17 15:22:24.818 [main] CamelAnnotationsHandler - Starting CamelContext with name [camelContext].
[INFO ] 2020-04-17 15:22:24.902 [main] DefaultManagementStrategy - JMX is enabled
[INFO ] 2020-04-17 15:22:25.308 [main] AbstractCamelContext - Apache Camel 3.2.0 (CamelContext: camel-1) is starting
[INFO ] 2020-04-17 15:22:25.438 [main] QuartzComponent - Create and initializing scheduler.
[INFO ] 2020-04-17 15:22:25.442 [main] QuartzComponent - Setting org.quartz.scheduler.jmx.export=true to ensure QuartzScheduler(s) will be enlisted in JMX.
[INFO ] 2020-04-17 15:22:25.483 [main] StdSchedulerFactory - Using default implementation for ThreadExecutor
[INFO ] 2020-04-17 15:22:25.487 [main] SimpleThreadPool - Job execution threads will use class loader of thread: main
[INFO ] 2020-04-17 15:22:25.511 [main] SchedulerSignalerImpl - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
[INFO ] 2020-04-17 15:22:25.511 [main] QuartzScheduler - Quartz Scheduler v.2.3.2 created.
[INFO ] 2020-04-17 15:22:25.516 [main] RAMJobStore - RAMJobStore initialized.
[INFO ] 2020-04-17 15:22:25.528 [main] QuartzScheduler - Scheduler meta-data: Quartz Scheduler (v2.3.2) 'DefaultQuartzScheduler-camel-1' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
[INFO ] 2020-04-17 15:22:25.528 [main] StdSchedulerFactory - Quartz scheduler 'DefaultQuartzScheduler-camel-1' initialized from an externally provided properties instance.
[INFO ] 2020-04-17 15:22:25.528 [main] StdSchedulerFactory - Quartz scheduler version: 2.3.2
[INFO ] 2020-04-17 15:22:25.529 [main] AbstractCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
[INFO ] 2020-04-17 15:22:25.623 [main] AbstractCamelContext - Route: myroute started and consuming from: direct://myroute
[INFO ] 2020-04-17 15:22:25.625 [main] AbstractCamelContext - Route: orderfault started and consuming from: direct://orderfault
[INFO ] 2020-04-17 15:22:25.637 [main] AbstractCamelContext - Total 2 routes, of which 2 are started
[INFO ] 2020-04-17 15:22:25.638 [main] AbstractCamelContext - Apache Camel 3.2.0 (CamelContext: camel-1) started in 0.329 seconds
[INFO ] 2020-04-17 15:22:25.663 [main] ScheduledRoutePolicy - Scheduled trigger: triggerGroup-myroute.trigger-START-myroute for action: START on route myroute
[INFO ] 2020-04-17 15:22:25.663 [main] ScheduledRoutePolicy - Scheduled trigger: triggerGroup-orderfault.trigger-START-orderfault for action: START on route orderfault
[INFO ] 2020-04-17 15:22:25.664 [main] QuartzComponent - Starting scheduler.
[INFO ] 2020-04-17 15:22:25.665 [main] QuartzScheduler - Scheduler DefaultQuartzScheduler-camel-1_$_NON_CLUSTERED started.
[INFO ] 2020-04-17 15:22:33.101 [main] MockEndpoint - Asserting: mock://test is satisfied
[INFO ] 2020-04-17 15:22:43.134 [main] MyRouterTest - ********************************************************************************
[INFO ] 2020-04-17 15:22:43.135 [main] MyRouterTest - Testing done: myRouteIsScheduledSuccessfully(com.telenet.atoms.eventengine.camel.MyRouterTest)
[INFO ] 2020-04-17 15:22:43.136 [main] MyRouterTest - Took: 17.469 seconds (17469 millis)
[INFO ] 2020-04-17 15:22:43.136 [main] MyRouterTest - ********************************************************************************
[INFO ] 2020-04-17 15:22:43.137 [main] CamelSpringBootExecutionListener - #RunWith(CamelSpringBootRunner.class) after: class com.telenet.atoms.eventengine.camel.MyRouterTest.myRouteIsScheduledSuccessfully
java.lang.AssertionError: mock://test Received message count. Expected: <2> but was: <0>
The SimpleScheduledRoutePolicy works as expected - it starts your Camel Route and that's what it is for: starting and stopping routes.
Because of your test, I guess that you want to have a Scheduler endpoint that triggers messages in a configured interval. For this you have to use Camel Timer, Camel Scheduler or Camel Quartz.
Since your route does not contain any of these, there is simply no scheduler that can be started.
To create a scheduler that (after waiting initially 5 seconds) fires every 3 seconds you can use for example this:
from("scheduler://foo?initialDelay=5s&delay=3s")...
Change at runtime (added due to comment)
The Camel Quartz component obviously uses the Quartz scheduler and Quartz provides a JMX access. So if you want to change the scheduler this is probably your best option.
To start and stop routes at runtime you should have a look at Camel Controlbus.

spring-boot-starter-quartz jdbc example

Starting with spring-boot 2.x.x they started offering spring-boot-starter-quartz which is great! Out of the box it does an in-memory store. I want to change it to be a clustered environment but I'm having issues with the configuration I think mostly because I need to put the qrtz_ tables in a different schema than my default data source. Does anyone have an example of using an alternate datasource? I'm currently attempting to set the properties field (as you can see below) but its like they are not being picked up by the configuration bean. Any help is appreciated.
Configuration
spring:
quartz:
job-store-type: jdbc
jdbc:
initialize-schema: never
properties:
scheduler:
instanceName : MyClusteredScheduler
instanceId : AUTO
threadPool:
class : org.quartz.simpl.SimpleThreadPool
threadCount : 25
threadPriority : 5
jobStore:
misfireThreshold : 60000
class : org.quartz.impl.jdbcjobstore.JobStoreTX
driverDelegateClass : org.quartz.impl.jdbcjobstore.StdJDBCDelegate
useProperties : false
dataSource : myDS
tablePrefix : QRTZ_
isClustered : true
clusterCheckinInterval : 20000
dataSource:
myDS:
driver : com.mysql.jdbc.Driver
URL : jdbc:mysql://127.0.0.1:3306/quartz
user : removed
password : removed
maxConnections : 5
validationQuery : select 0 from dual
Output from log
2017-11-06 13:33:02.853 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : Quartz Scheduler v.2.3.0 created.
2017-11-06 13:33:02.856 INFO 7082 --- [ main] o.s.s.quartz.LocalDataSourceJobStore : Using db table-based data access locking (synchronization).
2017-11-06 13:33:02.858 INFO 7082 --- [ main] o.s.s.quartz.LocalDataSourceJobStore : JobStoreCMT initialized.
2017-11-06 13:33:02.859 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : Scheduler meta-data: Quartz Scheduler (v2.3.0) 'quartzScheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore' - which supports persistence. and is not clustered.
2017-11-06 13:33:02.859 INFO 7082 --- [ main] org.quartz.impl.StdSchedulerFactory : Quartz scheduler 'quartzScheduler' initialized from an externally provided properties instance.
2017-11-06 13:33:02.860 INFO 7082 --- [ main] org.quartz.impl.StdSchedulerFactory : Quartz scheduler version: 2.3.0
2017-11-06 13:33:02.860 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : JobFactory set to: org.springframework.boot.autoconfigure.quartz.AutowireCapableBeanJobFactory#21132086
2017-11-06 13:33:03.214 INFO 7082 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-11-06 13:33:03.216 INFO 7082 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'dataSource' has been autodetected for JMX exposure
2017-11-06 13:33:03.223 INFO 7082 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'dataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=dataSource,type=HikariDataSource]
2017-11-06 13:33:03.227 INFO 7082 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 2147483647
2017-11-06 13:33:03.227 INFO 7082 --- [ main] o.s.s.quartz.SchedulerFactoryBean : Starting Quartz Scheduler now
2017-11-06 13:33:05.250 WARN 7082 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'quartzScheduler'; nested exception is org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: No database selected [See nested exception: java.sql.SQLException: No database selected]]
2017-11-06 13:33:05.250 INFO 7082 --- [ main] o.s.s.quartz.SchedulerFactoryBean : Shutting down Quartz Scheduler
2017-11-06 13:33:05.251 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : Scheduler quartzScheduler_$_NON_CLUSTERED shutting down.
2017-11-06 13:33:05.251 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : Scheduler quartzScheduler_$_NON_CLUSTERED paused.
2017-11-06 13:33:05.251 INFO 7082 --- [ main] org.quartz.core.QuartzScheduler : Scheduler quartzScheduler_$_NON_CLUSTERED shutdown complete.
2017-11-06 13:33:05.252 INFO 7082 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2017-11-06 13:33:05.253 INFO 7082 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
2017-11-06 13:33:05.254 INFO 7082 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-11-06 13:33:05.255 INFO 7082 --- [ main] com.zaxxer.hikari.HikariDataSource : testdb - Shutdown initiated...
2017-11-06 13:33:05.264 INFO 7082 --- [ main] com.zaxxer.hikari.HikariDataSource : testdb - Shutdown completed.
2017-11-06 13:33:05.265 INFO 7082 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2017-11-06 13:33:05.283 INFO 7082 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-11-06 13:33:05.293 ERROR 7082 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.context.ApplicationContextException: Failed to start bean 'quartzScheduler'; nested exception is org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: No database selected [See nested exception: java.sql.SQLException: No database selected]]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:186) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:52) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:358) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:159) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:884) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:122) ~[spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1233) [spring-boot-2.0.0.M5.jar:2.0.0.M5]
at com.tci.reader.incident.parser.IncidentParserApplication.main(IncidentParserApplication.java:18) [classes/:na]
Caused by: org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: No database selected [See nested exception: java.sql.SQLException: No database selected]]
at org.springframework.scheduling.quartz.SchedulerFactoryBean.start(SchedulerFactoryBean.java:738) ~[spring-context-support-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:183) ~[spring-context-5.0.0.RELEASE.jar:5.0.0.RELEASE]
... 14 common frames omitted
Caused by: org.quartz.SchedulerConfigException: Failure occured during job recovery.
at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:697) ~[quartz-2.3.0.jar:na]
at org.quartz.core.QuartzScheduler.start(QuartzScheduler.java:539) ~[quartz-2.3.0.jar:na]
at org.quartz.impl.StdScheduler.start(StdScheduler.java:142) ~[quartz-2.3.0.jar:na]
at org.springframework.scheduling.quartz.SchedulerFactoryBean.startScheduler(SchedulerFactoryBean.java:664) ~[spring-context-support-5.0.0.RELEASE.jar:5.0.0.RELEASE]
at org.springframework.scheduling.quartz.SchedulerFactoryBean.start(SchedulerFactoryBean.java:735) ~[spring-context-support-5.0.0.RELEASE.jar:5.0.0.RELEASE]
... 15 common frames omitted
Caused by: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: No database selected
at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:157) ~[quartz-2.3.0.jar:na]
at org.quartz.impl.jdbcjobstore.DBSemaphore.obtainLock(DBSemaphore.java:113) ~[quartz-2.3.0.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3842) ~[quartz-2.3.0.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.recoverJobs(JobStoreSupport.java:839) ~[quartz-2.3.0.jar:na]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.schedulerStarted(JobStoreSupport.java:695) ~[quartz-2.3.0.jar:na]
... 19 common frames omitted
Caused by: java.sql.SQLException: No database selected
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2487) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1966) ~[mysql-connector-java-5.1.44.jar:5.1.44]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52) ~[HikariCP-2.7.2.jar:na]
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java) ~[HikariCP-2.7.2.jar:na]
at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:96) ~[quartz-2.3.0.jar:na]
... 23 common frames omitted
You have to use the correct properties for the quartz properties.
Your properties are missing ...org.quartz...
For the none-yml notation, try this for the threadCount:
spring.quartz.properties.org.quartz.threadPool.threadCount=25
For the yml notation:
Add two layers under the 'properties', e.g.
spring:
quartz:
properties:
org:
quartz:
threadPool:
threadCount : 25
Application.yml file:
spring:
jpa:
hibernate:
ddl-auto: none
datasource:
url: jdbc:mysql://127.0.0.1:3306/Quartz
username: Your Username
password: Your Password
quartz:
scheduler:
instanceName: Scheduler
threadPool:
class: org.quartz.simpl.SimpleThreadPool
threadCount: 3
context:
key:
QuartzTopic: QuartzPorperties
jobStore:
driver: com.mysql.jdbc.Driver
class: org.quartz.impl.jdbcjobstore.JobStoreTX
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
misfireThreshold: 6000
tablePrefix: QRTZ_
Next create a Configuration class which reads these properties from the yml file and then creates a Scheduler Bean:
#Configuration
public class SchedulerConfig {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
#Value("${quartz.scheduler.instanceName}")
private String instanceName;
#Value("${quartz.threadPool.class}")
private String threadClass;
#Value("${quartz.threadPool.threadCount}")
private String threadCount;
#Value("${quartz.context.key.QuartzTopic}")
private String quartzTopic;
#Value("${quartz.jobStore.class}")
private String jobStoreClass;
#Value("${quartz.jobStore.driverDelegateClass}")
private String driverDelegateClass;
#Value("${quartz.jobStore.misfireThreshold}")
private String misfireThreshold;
#Value("${quartz.jobStore.tablePrefix}")
private String tablePrefix;
#Value("${quartz.jobStore.driver}")
private String dataSourceDriver;
#Value("${spring.datasource.url}")
private String dataSourceUrl;
#Value("${spring.datasource.username}")
private String dataSourceUsername;
#Value("${spring.datasource.password}")
private String databasePassword;
#Bean({"Scheduler"})
public Scheduler getScheduler() {
Scheduler scheduler = null;
try {
StdSchedulerFactory factory = new StdSchedulerFactory();
Properties props = new Properties();
props.put("org.quartz.scheduler.instanceName", instanceName);
props.put("org.quartz.threadPool.class", threadClass);
props.put("org.quartz.threadPool.threadCount", threadCount);
props.put("org.quartz.context.key.QuartzTopic", quartzTopic);
props.put("org.quartz.jobStore.class", jobStoreClass);
props.put("org.quartz.jobStore.driverDelegateClass", driverDelegateClass);
props.put("quartz.jobStore.misfireThreshold", misfireThreshold);
props.put("org.quartz.jobStore.tablePrefix", tablePrefix);
props.put("org.quartz.jobStore.dataSource", "myDS");
props.put("org.quartz.dataSource.myDS.driver", dataSourceDriver);
props.put("org.quartz.dataSource.myDS.URL", dataSourceUrl);
props.put("org.quartz.dataSource.myDS.user", dataSourceUsername);
props.put("org.quartz.dataSource.myDS.password", databasePassword);
props.put("org.quartz.dataSource.myDS.maxConnections", "10");
factory.initialize(props);
scheduler = factory.getScheduler();
scheduler.start();
scheduler.resumeAll(); // This is to resume the entire scheduler when a new build is deployed
} catch (Exception e) {
logger.error("{} - SchedulerConfig class - getScheduler() - Error creating Scheduler instance: {}",
appName, e);
}
return scheduler;
}
}
Finally, use the Bean as below in any class you want:
#Autowired
private Scheduler scheduler;

JHipster and mongodb : Error creating bean with name 'mongobee'

I am rather new to JHipster and I followed their instructions in order to create a new app.
The app was created, imported into STS as a Maven project and I updated it.
However as soon as I try to start it via the Boot Dashboard I get this output :
2016-12-07 16:43:14.887 INFO 6396 --- [ restartedMain] com.mycompany.myapp.MdcApp : Starting MdcApp on PC981 with PID 6396 (C:\Users\lvuillaume\Desktop\mdc\target\classes started by lvuillaume in C:\Users\lvuillaume\Desktop\mdc)
2016-12-07 16:43:14.890 DEBUG 6396 --- [ restartedMain] com.mycompany.myapp.MdcApp : Running with Spring Boot v1.4.2.RELEASE, Spring v4.3.4.RELEASE
2016-12-07 16:43:14.891 INFO 6396 --- [ restartedMain] com.mycompany.myapp.MdcApp : The following profiles are active: swagger,dev
2016-12-07 16:43:14.972 DEBUG 6396 --- [kground-preinit] org.jboss.logging : Logging Provider: org.jboss.logging.Slf4jLoggerProvider found via system property
2016-12-07 16:43:18.499 DEBUG 6396 --- [ restartedMain] c.m.myapp.config.AsyncConfiguration : Creating Async Task Executor
2016-12-07 16:43:19.041 DEBUG 6396 --- [ restartedMain] c.m.myapp.config.MetricsConfiguration : Registering JVM gauges
2016-12-07 16:43:19.059 DEBUG 6396 --- [ restartedMain] c.m.myapp.config.MetricsConfiguration : Initializing Metrics JMX reporting
2016-12-07 16:43:19.960 WARN 6396 --- [ restartedMain] io.undertow.websockets.jsr : UT026009: XNIO worker was not set on WebSocketDeploymentInfo, the default worker will be used
2016-12-07 16:43:19.961 WARN 6396 --- [ restartedMain] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
2016-12-07 16:43:20.436 INFO 6396 --- [ restartedMain] c.mycompany.myapp.config.WebConfigurer : Web application configuration, using profiles: [swagger, dev]
2016-12-07 16:43:20.437 DEBUG 6396 --- [ restartedMain] c.mycompany.myapp.config.WebConfigurer : Initializing Metrics registries
2016-12-07 16:43:20.442 DEBUG 6396 --- [ restartedMain] c.mycompany.myapp.config.WebConfigurer : Registering Metrics Filter
2016-12-07 16:43:20.442 DEBUG 6396 --- [ restartedMain] c.mycompany.myapp.config.WebConfigurer : Registering Metrics Servlet
2016-12-07 16:43:20.445 INFO 6396 --- [ restartedMain] c.mycompany.myapp.config.WebConfigurer : Web application fully configured
2016-12-07 16:43:20.491 INFO 6396 --- [ restartedMain] com.mycompany.myapp.MdcApp : Running with Spring profile(s) : [swagger, dev]
2016-12-07 16:43:20.579 DEBUG 6396 --- [ restartedMain] c.m.myapp.config.CacheConfiguration : No cache
2016-12-07 16:43:24.805 DEBUG 6396 --- [ restartedMain] c.m.m.c.apidoc.SwaggerConfiguration : Starting Swagger
2016-12-07 16:43:24.816 DEBUG 6396 --- [ restartedMain] c.m.m.c.apidoc.SwaggerConfiguration : Started Swagger in 10 ms
2016-12-07 16:43:24.849 DEBUG 6396 --- [ restartedMain] c.m.myapp.config.DatabaseConfiguration : Configuring Mongobee
2016-12-07 16:43:24.854 INFO 6396 --- [ restartedMain] com.github.mongobee.Mongobee : Mongobee has started the data migration sequence..
2016-12-07 16:43:54.876 WARN 6396 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongobee' defined in class path resource [com/mycompany/myapp/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
2016-12-07 16:43:54.883 INFO 6396 --- [ restartedMain] c.m.myapp.config.CacheConfiguration : Closing Cache Manager
2016-12-07 16:43:54.905 ERROR 6396 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongobee' defined in class path resource [com/mycompany/myapp/config/DatabaseConfiguration.class]: Invocation of init method failed; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:754)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at com.mycompany.myapp.MdcApp.main(MdcApp.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused: connect}}]
at com.mongodb.connection.BaseCluster.createTimeoutException(BaseCluster.java:369)
at com.mongodb.connection.BaseCluster.selectServer(BaseCluster.java:101)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:75)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.<init>(ClusterBinding.java:71)
at com.mongodb.binding.ClusterBinding.getReadConnectionSource(ClusterBinding.java:63)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:210)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:482)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:79)
at com.mongodb.Mongo.execute(Mongo.java:772)
at com.mongodb.Mongo$2.execute(Mongo.java:759)
at com.mongodb.DBCollection.findOne(DBCollection.java:777)
at com.mongodb.DBCollection.findOne(DBCollection.java:747)
at com.mongodb.DBCollection.findOne(DBCollection.java:694)
at com.github.mongobee.dao.ChangeEntryIndexDao.findRequiredChangeAndAuthorIndex(ChangeEntryIndexDao.java:26)
at com.github.mongobee.dao.ChangeEntryDao.ensureChangeLogCollectionIndex(ChangeEntryDao.java:75)
at com.github.mongobee.dao.ChangeEntryDao.connectMongoDb(ChangeEntryDao.java:34)
at com.github.mongobee.Mongobee.execute(Mongobee.java:135)
at com.github.mongobee.Mongobee.afterPropertiesSet(Mongobee.java:117)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1642)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1579)
... 19 common frames omitted
I tried to create a similar project but without a Mongodb and it worked.
This error means that there was an error connecting to your database, it confirms this in your stacktrace:
Timed out after 30000 ms while waiting for a server
Please double check your database configuration in the application-dev.properties or application-dev.yml file under src/main/resources/config/.
Depending on whether you use YAML or JSON as the property definition file, double check the database configuration:
YAML:
spring:
data:
mongodb:
host: <your_host_address>
port: <your_port>
database: <database_name>
JSON:
spring.data.mongodb.host=<your_host_address>
spring.data.mongodb.port=<your_port>
spring.data.mongodb.database=<database_name>
After creating a new JHipster project with MongoDb I had the same error.
Before running mvnw (on Windows) I forgot to run the MongoDb itself.
So running mongod.exe in the new command prompt, and then running mvnw solved the issue for me.
This was able to solve my problem:
"Answered my own question...removing the #Bean definition from public
Mongobee mongobee(...) in DatabaseConfiguration.java seems to do the
trick. Haven't done any thorough testing, but the apps starts and I
can create new users."
Link: https://github.com/jhipster/generator-jhipster/issues/8665

tomcat8 spring-boot war memory leak

I have an application that is working on tomcat8 , on repeated undeploy/deploy (i use parallel versions) i noticed that the server memory increase also on tomacat manager clicking on find leaks shows the below
The following web applications were stopped (reloaded, undeployed),
but their classes from previous runs are still loaded in memory, thus
causing a memory leak (use a profiler to confirm): /
i tried to use profiler to check what is still in memory but could not figure out , as i did not know where to start with .
stopping the application show the below log
2016-11-03 05:50:25.388 [ ] INFO 29986 --- [http-nio-8080-exec-34] o.a.c.c.C.[.[.teltacworldwide.co].[/] : Destroying Spring FrameworkServlet 'dispatcherServlet'
2016-11-03 05:50:25.392 [ ] INFO 29986 --- [http-nio-8080-exec-34] o.a.c.c.C.[.[.teltacworldwide.co].[/] : Closing Spring root WebApplicationContext
2016-11-03 05:50:25.393 [ ] INFO 29986 --- [http-nio-8080-exec-34] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#7fe83fea: startup date [Wed Nov 02 15:09:26 GMT 2016]; root of context hierarchy
2016-11-03 05:50:25.403 [ ] INFO 29986 --- [http-nio-8080-exec-34] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 2147483647
2016-11-03 05:50:25.411 [ ] INFO 29986 --- [http-nio-8080-exec-34] o.s.m.s.s.StompBrokerRelayMessageHandler : Stopping...
2016-11-03 05:50:25.412 [ ] INFO 29986 --- [http-nio-8080-exec-34] o.s.m.s.s.StompBrokerRelayMessageHandler : BrokerAvailabilityEvent[available=false, StompBrokerRelay[192.168.70.149:61613]]
2016-11-03 05:50:25.465 [ ] WARN 29986 --- [globalEventExecutor-1-2] io.netty.channel.AbstractChannel : Can't invoke task later as EventLoop rejected it
java.util.concurrent.RejectedExecutionException: event executor terminated
at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:715) ~[netty-all-4.0.31.Final.jar:4.0.31.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:300) ~[netty-all-4.0.31.Final.jar:4.0.31.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:691) ~[netty-all-4.0.31.Final.jar:4.0.31.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.invokeLater(AbstractChannel.java:826) [netty-all-4.0.31.Final.jar:4.0.31.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe.access$800(AbstractChannel.java:378) [netty-all-4.0.31.Final.jar:4.0.31.Final]
at io.netty.channel.AbstractChannel$AbstractUnsafe$5.run(AbstractChannel.java:571) [netty-all-4.0.31.Final.jar:4.0.31.Final]
at io.netty.util.concurrent.GlobalEventExecutor$TaskRunner.run(GlobalEventExecutor.java:233) [netty-all-4.0.31.Final.jar:4.0.31.Final]
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [netty-all-4.0.31.Final.jar:4.0.31.Final]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]

Resources