Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource

How can i solve this problem? Which is best choice and how to do that

  1. set unique poolName
  2. destroy previous connection pool

error message screenshot

org.apache.catalina.core.ApplicationContext.log Initializing Spring embedded WebApplicationContext
11-Aug-2018 16:05:53.863 SEVERE [Catalina-startStop-1] org.apache.catalina.core.ContainerBase.startInternal A child container failed during start
 java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[sss].StandardContext[]]
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at ..........
...............
......
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[sss].StandardContext[]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        ... 6 more
Caused by: org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [HikariDataSource (HikariPool-2)] with key 'dataSource'; nested exception is javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource
        at org.springframework.jmx.export.MBeanExporter.registerBeanNameOrInstance(MBeanExporter.java:625)
        at 
..........................

org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5245)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        ... 6 more
Caused by: javax.management.InstanceAlreadyExistsException: com.zaxxer.hikari:name=dataSource,type=HikariDataSource
        at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:437)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerWithRepository(DefaultMBeanServerInterceptor.java:1898)
        at .................
............
        at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:522)`
like image 465
Naranmandakh Tsogoo Avatar asked Aug 11 '18 08:08

Naranmandakh Tsogoo


1 Answers

There are two ways to solve this problem.

i. Disable jmx

ii. set default-domain and unique name( its required if you want to enable jmx and have multiple instance of same application)

For disable jmx:

application.yml:

spring:
  jmx:
    enabled: false

or application.properties:

spring.jmx.enabled= false

Set below properties if need to enable jmx.

application.yml:

spring:
  jmx:
    default-domain: com.application.name
    unique-names: true

or application.properties:

spring.jmx.default-domain=com.application.name
like image 145
GolamMazid Sajib Avatar answered Oct 21 '22 21:10

GolamMazid Sajib