Chengkun Li created DBCP-533:
--------------------------------

             Summary: tomcat register MBean of BasicDataSource with jmxName , 
appear InstanceAlreadyExistsException
                 Key: DBCP-533
                 URL: https://issues.apache.org/jira/browse/DBCP-533
             Project: Commons DBCP
          Issue Type: Bug
    Affects Versions: 2.0
         Environment: tomcat 8.5.32 
            Reporter: Chengkun Li
         Attachments: 20181221101406115.png, 20181221101456927.png

I need monitoring connection of DBCP2 in tomcat ,but does not find how to use 
JMX in  [http://commons.apache.org/proper/commons-dbcp/configuration.html]

through reading the source code ,i find jmxName properties in 

BasicDataSourceFactory ,when I add the setting like 

jmxName="org.apache.dbcp:DataSource=mydb" in server.xml , there is 
javax.management.InstanceAlreadyExistsException: 
org.apache.dbcp:DataSource=mysqldb

when I start up tomcat.

after I debug the code , i find that DBCP have registered the Mbean in 
BasicDataSource with jmxName (BasicDataSource line 2390)  ,but tomcat will  
register the Component in the startup lifecycle , tomcat will use the 
BasicDataSource's preRegister method to get the same Mbean name, because 
BasicDataSource  implements MBeanRegistration.

BUT i'm not certain that it's a bug or I use it wrong



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to