I am trying to access DataSource ConnectionManager MBean using java client.I am able to access it when I specify the datasource name and JNDI name in Object Name.I need a generic approach which can be applicabe for any datasource in server.xml, since this is done as part of a framework that can be used in any application.
I tried multiple options but all the time I got 'javax.management.InstanceNotFoundException'.
Sample code is as given below:
<library id="oracle-lib">
<fileset dir="lib" includes="ojdbc6.jar"/>
</library>
<dataSource jndiName="jdbc/db" id="oracleDB" type="javax.sql.DataSource">
<jdbcDriver javax.sql.DataSource="oracle.jdbc.pool.OracleConnectionPoolDataSource" libraryRef="oracle-lib" />
<connectionManager agedTimeout="10" maxIdleTime="1800" connectionTimeout="180" minPoolSize="10" maxPoolSize="1" reapTime="180"/>
<properties.oracle user="user" password="password"
url="jdbc:oracle:thin:@//db-server:1521/db"/>
</dataSource>
Object name that worked:
ObjectName jvmQuery = new ObjectName("WebSphere:type=com.ibm.ws.jca.cm.mbean.ConnectionManagerMBean,jndiName=jdbc/db,name=dataSource[oracleDB]/ConnectionManager[default-0]")
Generic Object Names I tried:
1.WebSphere:type=com.ibm.ws.jca.cm.mbean.ConnectionManagerMBean,*
2.WebSphere:type=com.ibm.ws.jca.cm.mbean.ConnectionManagerMBean,name=dataSource[default-0]/ConnectionManager[default-0],*
3.WebSphere:service=com.ibm.ws.jca.cm.mbean.ConnectionManagerMBean,*
4.WebSphere:service=com.ibm.ws.jca.cm.mbean.ConnectionManagerMBean,name=dataSource[default-0]/ConnectionManager[default-0],*
5.WebSphere:service=com.ibm.ws.jca.cm.mbean.ConnectionManagerMBean,name=dataSource[default-0]/ConnectionManager[default-0]
Could you please advise..
Thank you, Biju
Query option #1 should work fine:
WebSphere:type=com.ibm.ws.jca.cm.mbean.ConnectionManagerMBean,*
I just tested it with several data sources in my configuration and got the following:
Found MBean: WebSphere:type=com.ibm.ws.jca.cm.mbean.ConnectionManagerMBean,jndiName=jdbc/ds1,name=dataSource[ds1]/connectionManager
Found MBean: WebSphere:type=com.ibm.ws.jca.cm.mbean.ConnectionManagerMBean,jndiName=jdbc/ds2,name=dataSource[ds2]/connectionManager
Found MBean: WebSphere:type=com.ibm.ws.jca.cm.mbean.ConnectionManagerMBean,jndiName=jdbc/ds3,name=dataSource[ds3]/connectionManager[default-0]
Found MBean: WebSphere:type=com.ibm.ws.jca.cm.mbean.ConnectionManagerMBean,jndiName=jdbc/XAds,name=dataSource[XAds]/connectionManager
Keep in mind that Connection Manager MBeans are lazily created. If you are expecting to find an mbean in a query, make sure that you have gotten a connection from the data source before. Getting a connection from the data source will force a Connection Manager (and its MBean) to be created.