Can't see JMX entries in jconsole when using Tomcat JDBC Connection Pool
Asked Answered
P

4

7

we're evaluating switching over from the C3P0 connection pool to the Tomcat JDBC Connection Pool (as described here).

It appears to work as a connection pool but I can't seem to see any JMX entries for it when I run jconsole.
Out of the box C3P0 gives lots of operations and attributes via JMX, the Tomcat JDBC Connection Pool gives none (for me).

According to the page linked above there is a jmxEnabled flag that defaults to true. I've set this explicitly but it seems to make no difference.

What am I missing?

I'm running a fairly standard Java6/Spring/Hibernate app by the way.

Pinna answered 5/10, 2010 at 15:57 Comment(2)
are you using SpringSource tc Server? That article mentions that the "Tomcat JDBC Connection Pool" is only available in SpringSource's distribution of Tomcat (which makes the name of the connection pool a poor choice, IMO)Lassalle
No we're not but our app runs fine with it on Tomcat 6, and another app has been using it for a few months on Tomcat 6 too.Pinna
S
12

If you configure pool in your spring context, you should export bean manually. Autoexport works only if you confiugre pool in tomcat container and import it from JNDI. See http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html#JMX

You may use this spring config for export pool information to JMX:

<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource">
   ... skipped ...
</bean>

<bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
    <property name="beans">
        <map>
            <entry key="bean:name=DataSource" value="#{dataSource.getPool().getJmxPool()}"/>
        </map>
    </property>
</bean>

Config works only in Spring version 3.0 and above, because it uses spring expression language

Schaffner answered 2/9, 2012 at 3:42 Comment(2)
Thanks for this, it helped me. For some reason, the pool wasn't initialized by using this technique directly, so I had to change it to <entry key="bean:name=DataSource" value="#{dataSource.createPool().getJmxPool()}"/> to get it to workMarquittamarr
@JohnC probably a timing issue, you want jmxExporter to export after dataSource is initialized, not before; did you try this? <bean id="jmxExporter" depends-on="dataSource"/>Precautious
M
0

Do you see any entries under the tree

Catalina -> DataSource -> javax.sql.DataSource

This lists the number of active connections, idle connections, and a few other common stats. Other then that, what kind of information are you hoping to get out of monitoring?

Merrileemerrili answered 5/10, 2010 at 17:17 Comment(2)
I don't have a DataSource entry under Catalina.Pinna
I also Don't see this entry. I am using Spring 3 with DBCP pool on Tomcat 5 using jdk 5John
C
0

Darren, if you don't see the object name under Catalina/DataSource/javax.sql.DataSource/<name> in JConsole, then I wonder if the datasource is defined incorrectly or perhaps it was not connected to the database when Tomcat was started.

Bruce

Cupbearer answered 17/11, 2010 at 22:24 Comment(3)
I am using spring and DBCP data source. I did not see catalina/DataSource in Jconsole. kindly give me Insights how to monitor pool size when using Spring 3 and DBCP connection pool.John
Here is a Maven project that makes use of Spring 3 to expose a DBCP connection pool via JMX: github.com/bsnyder/spring-jdbc-jmx Note: There is a Thread.sleep in the App.select() method so that you can start up jconsole to peek at the JMX properties of the DataSource object.Cupbearer
Wao... You are great. Thanks allot. That's what I am looking for :-)John
W
0
In support of Sean's post:

The placement of the javax.sql.DataSource entry in MBeans of JConsole is:

  • Catalina
    • DataSource
      • /[Name_of_deployed_application] // e.g. "/DomainService
        • /[Host_name_of_the_deployed_application] //e.g. "localhost"
          • javax.sql.DataSource
Waly answered 19/2, 2018 at 17:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.