I am trying to deploye two WAR files (app1.war and app2.war) on the same tomcat7 instance. I am getting this error :
Unable to register MBean [HikariDataSource (HikariPool-0)] with key
'dataSource'; nested exception is javax.management.InstanceAlreadyExistsException:
com.zaxxer.hikari:name=dataSource,type=HikariDataSource
I don't have this error if I have only one application deployed on tomcat. Is there a way to solve this issue?
in spring boot, jmx bean is loaded at run time and it scans your application. If two data sources are found, its going to throw javax.management.InstanceAlreadyExistsException. This can be resolved by defining the default jmx default domain name in your application.properties file as follows
spring.jmx.default-domain=app_name
I hope this helps.
In Spring Boot you can change the name of the Hikari data source pool via application.properties:
spring.datasource.hikari.poolName=MyDataPoolName
or application.yml respectivly:
spring:
datasource:
hikari:
pool-name: MyDataPoolName
Then Tomcat can load both applications and the name conflict is gone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With