[javamelody] Problem monitoring JDBC with JAVAMELODY

1,416 views
Skip to first unread message

KiLiCoOl

unread,
May 17, 2010, 10:27:34 AM5/17/10
to javam...@googlegroups.com
Hi,

I've a problem with the monitoring of JDBC datasource with Javamelody.

I follow all your instructions but i can't make this work ! Still "0" in JDBC Connection Active

For your information, i bind the datasource with C3P0 in my Spring applicationContext.xml file.

I load this applicationContext.xml file in a listner I make who is loaded by web.xml in a <listener-class>

Can someone help me ?

Regards,
Julien

Emeric Vernat

unread,
May 17, 2010, 5:52:58 PM5/17/10
to javam...@googlegroups.com
Bonjour Julien !

Cela fait plaisir de voir quelques français et bienvenue à toi.

For your spring datasource, can you post an extract of your datasource definition from your applicationContext.xml file?
And do you include "classpath:net/bull/javamelody/monitoring-spring.xml" with "applicationContext.xml" in your <listener-class> of the web.xml file? (as said here: http://code.google.com/p/javamelody/wiki/UserGuide#7._JDBC )

A bientôt, Emeric

KiLiCoOl

unread,
May 18, 2010, 3:59:18 AM5/18/10
to javam...@googlegroups.com
Hi !

Are you french too ?

Here is my datasource (C3P0) from applicationContext.xml file

 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
      <property name="driverClass"><value>com.mysql.jdbc.Driver</value></property>
      <property name="jdbcUrl"><value>jdbc:mysql://leader-mysql-dev/novanet_pprod?autoReconnect=true</value></property>
      <property name="user"><value>XX</value></property>
      <property name="password"><value>XX</value></property>
      <property name="checkoutTimeout"><value>${checkoutTimeout}</value></property>
       <property name="minPoolSize"><value>${minPoolSizeSpring}</value></property>
       <property name="maxPoolSize"><value>${maxPoolSizeSpring}</value></property>
       <property name="maxIdleTime"><value>${maxIdleTime}</value></property>
       <property name="maxConnectionAge"><value>${maxConnectionAge}</value></property>
       <property name="acquireIncrement"><value>${acquireIncrement}</value></property>
       <property name="maxStatements"><value>${maxStatements}</value></property>
       <property name="propertyCycle"><value>${propertyCycle}</value></property>
       <property name="unreturnedConnectionTimeout"><value>${unreturnedConnectionTimeout}</value></property>
       <property name="autoCommitOnClose"><value>${autoCommitOnClose}</value></property>
       <property name="preferredTestQuery"><value>${preferredTestQuery}</value></property>
       <property name="debugUnreturnedConnectionStackTraces"><value>true</value></property>
  </bean>

And this is the contextInitialized method of my listener

                        BeanFactory factory = new ClassPathXmlApplicationContext("net/bull/javamelody/monitoring-spring.xml");
     ServletContext context = contextEvent.getServletContext();
     System.setProperty(VariableNames.PATH_NAME.toString(),context.getContextPath());
     System.setProperty(VariableNames.JVM_NOVANET_DIR.toString(), System.getenv().get(VariableNames.NOVANET_DIR.toString()));
     ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
     SpringBeanProvider.setApplicationContext(applicationContext);

Best regards,
Julien

Emeric Vernat

unread,
May 18, 2010, 4:11:30 PM5/18/10
to javam...@googlegroups.com
Hi,

Yes I'm french, near Paris.

The datasource definition looks good.

But I do not see what do you do with the local variable factory after: BeanFactory factory = new ClassPathXmlApplicationContext("net/bull/javamelody/monitoring-spring.xml");

In my case, the following example works fine and I have monitoring of jdbc connections:
ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {
                "net/bull/javamelody/monitoring-spring.xml", "applicationContext.xml" });
DataSource dataSource = (DataSource) context.getBean("dataSource");

Bye, Emeric

KiLiCoOl

unread,
May 18, 2010, 4:17:30 PM5/18/10
to javam...@googlegroups.com
Hi back,

We could speak french so ? :)

In fact, I'm not using factory variable, It've just declare it to load monitoring-spring at first !

You think if I load my 2 files with your method, this should work ?

Best regards,
Julien

Emeric Vernat

unread,
May 18, 2010, 4:30:07 PM5/18/10
to javam...@googlegroups.com
Le 18/05/2010 22:17, KiLiCoOl a écrit :
Hi back,

We could speak french so ? :)
Oui.



In fact, I'm not using factory variable, It've just declare it to load monitoring-spring at first !

You think if I load my 2 files with your method, this should work ?

Oui ! Il faut charger les 2 fichiers. (Le post-processor dans le fichier xml est utile pour les connexions jdbc.)

Best regards,
Meilleurs regards ;-)

KiLiCoOl

unread,
May 19, 2010, 2:54:21 AM5/19/10
to javam...@googlegroups.com
Hey again !

Now it works ! I think ! Let see together if you want ;) (see attachment infos.jpg)

The windows "Hits SQL", "Temps SQL" and "% Erreur SQL" now have informations and not "NAN", so I think it's good ! But, I still have 
"Nb de connexions jdbc actives" & "Nb de connexions jdbc utilisées (ouvertes si pas de datasource)" = 0, Is that normal ?

Let's talk a little bit french !

Un grand merci pour ta contribution au monde de Java, ton outil de monitoring m'a bien aidé à de nombreuses reprises et je le trouve de plus en plus intéressant ! BRAVO !!!! Tu travailles seul dessus ? Sinon de mon coté je développe des outils en Java / J2EE dans le Nord à Lille :)

Tiens petite question, j'ai vu dans la doc le paragraphe suivant "The parameter log can activate logs of http requests (false by default). The http request will be logged with duration and size of the response in the log category corresponding to the name of the filter set in web.xml file, using Log4J if it is present in your application, or using java.util.logging otherwise"

Tu parles bien des requêtes HTTP comme elle pourrait être logguer via TOMCAT avec un "<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs">" ?

Comment dois je le paramétrer alors ? Dans le web.xml ?

<init-param> <param-name>log</param-name> <param-value>???</param-value> </init-param>

Merci !
Julien
infos.jpg

Emeric Vernat

unread,
May 19, 2010, 3:36:26 PM5/19/10
to javam...@googlegroups.com
Hi,


Le 19/05/2010 08:54, KiLiCoOl a écrit :
Hey again !

Now it works ! I think ! Let see together if you want ;) (see attachment infos.jpg)

The windows "Hits SQL", "Temps SQL" and "% Erreur SQL" now have informations and not "NAN", so I think it's good ! But, I still have 
"Nb de connexions jdbc actives" & "Nb de connexions jdbc utilisées (ouvertes si pas de datasource)" = 0, Is that normal ?

It is probably normal to have 0 jdbc connections used/active at first.
Just put some heavy load or some very long sql request for more than 1 minute and you should see something different than 0.

Let's talk a little bit french !

Un grand merci pour ta contribution au monde de Java, ton outil de monitoring m'a bien aidé à de nombreuses reprises et je le trouve de plus en plus intéressant ! BRAVO !!!! Tu travailles seul dessus ? Sinon de mon coté je développe des outils en Java / J2EE dans le Nord à Lille :)
Merci. Et oui seul actuellement, mais j'accepte les contributions (blogs, traductions, tests & bugs, avec patchs ou workarounds c'est encore mieux, docs...)

Tiens petite question, j'ai vu dans la doc le paragraphe suivant "The parameter log can activate logs of http requests (false by default). The http request will be logged with duration and size of the response in the log category corresponding to the name of the filter set in web.xml file, using Log4J if it is present in your application, or using java.util.logging otherwise"

Tu parles bien des requêtes HTTP comme elle pourrait être logguer via TOMCAT avec un "<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs">" ?
Oui les requêtes http, mais pas avec le même format que AccessLogValve.
Comment dois je le paramétrer alors ? Dans le web.xml ?

<init-param>
<param-name>log</param-name>
<param-value>???</param-value>
</init-param>

Comme ceci dans le web.xml après <filter-class> :
<init-param>
<param-name>log</param-name>
<param-value>true</param-value>
</init-param>

KiLiCoOl

unread,
May 19, 2010, 3:54:11 PM5/19/10
to javam...@googlegroups.com
Merci bien !

Sache que c'est ce que j'ai fait pour le paramètre LOG à TRUE mais je ne vois aucun logs nul part, où se génèrent t'ils ?

Julien

Emeric Vernat

unread,
May 19, 2010, 4:18:10 PM5/19/10
to javam...@googlegroups.com
In English for other people:
If the parameter log is true, then JavaMelody write at the INFO level using logback, log4j or java.util.logging depending available classes.

You could check the configuration of logback, log4j or java.util.logging to verify that INFO messages are actually written in the log and if the log goes to stdout or to a file.

bye, Emeric
Reply all
Reply to author
Forward
0 new messages