現在Java,SpringBoot,MySQL,TomcatでWebアプリケーションを作っています。
負荷テストを実施していて1分間で240スレッドのテストを実施したい際に以下のようなエラーになったので解決したいです。
log
1org.springframework.transaction.CannotCreateTransactionException: 2Could not open JDBC Connection for transaction; nested exception is 3java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, 4 request timed out after 30000ms.
Tomcatのバージョンは8.52です。
SpringBootの設定ファイル(application.yml)で以下のような設定を入れました。
yml
1spring: 2 datasource: 3 continue-on-error: false 4 driver-class-name: com.mysql.jdbc.Driver 5 initialization-mode: never 6# type: org.apache.tomcat.jdbc.pool.DataSource 7 tomcat: 8 max-active: 300
もともと動いていたところにmax-active: 300を入れました。
しかし、負荷テストの結果は同じで負荷に耐え切れず上記のようなエラーが出ました。
type: org.apache.tomcat.jdbc.pool.DataSource
が必要だと思ったのですが、コメントを外すとwebサーバー起動時にエラーが出てそれを解決できずにいます。
console
12018-11-01 14:17:30.689 ERROR 6916 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'sessionRepositoryFilterRegistration' defined in class path resource [org/springframework/boot/autoconfigure/session/SessionRepositoryFilterConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepositoryFilterRegistration' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springSessionRepositoryFilter' defined in class path resource [org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.class]: Unsatisfied dependency expressed through method 'springSessionRepositoryFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRepository' defined in class path resource [org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepository' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springSessionJdbcOperations' defined in class path resource [org/springframework/session/jdbc/config/annotation/web/http/JdbcHttpSessionConfiguration.class]: Unsatisfied dependency expressed through method 'springSessionJdbcOperations' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Generic.class]: Unsatisfied dependency expressed through method 'dataSource' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Could not bind properties to 'DataSourceProperties' : prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.type' to java.lang.Class<javax.sql.DataSource> 22018-11-01 14:17:30.704 INFO 6916 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
負荷テストのエラーを解決する方法(おそらくコネクションプールの数を広げる)を教えていただけないでしょうか?
上記のエラーも踏まえてわかる方がいればお願い致します。