Monitoring c3p0 ComboPooledDataSources

519 views
Skip to first unread message

makikaze

unread,
Jul 18, 2011, 4:43:06 AM7/18/11
to javamelody
Can I monitor connections made by c3p0 ComboPooledDataSources in
javamelody? I've tried to do this but it seems to doesn't work. It
fails while datasources rebinding:

10:24:13,911 DEBUG [net.bull.javamelody] rebinding datasources failed,
skipping
javax.naming.OperationNotSupportedException: Can only bind References
or Referenceable objects
at
com.sun.jndi.fscontext.RefFSContext.addObjectToBindings(RefFSContext.java:
479)
at com.sun.jndi.fscontext.RefFSContext.bindObject(RefFSContext.java:
337)
at com.sun.jndi.fscontext.RefFSContext.rebind(RefFSContext.java:189)
at
com.sun.jndi.toolkit.url.GenericURLContext.rebind(GenericURLContext.java:
231)
at javax.naming.InitialContext.rebind(InitialContext.java:408)
at
net.bull.javamelody.JdbcWrapperHelper.rebindDataSource(JdbcWrapperHelper.java:
57)
at net.bull.javamelody.JdbcWrapper.rebindDataSources(JdbcWrapper.java:
428)
at net.bull.javamelody.FilterContext.<init>(FilterContext.java:78)
at net.bull.javamelody.MonitoringFilter.init(MonitoringFilter.java:
70)
at
org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:
273)
at
org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:
254)
at
org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:
372)
at
org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:
98)
at
org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:
4542)
at org.apache.catalina.core.StandardContext
$2.call(StandardContext.java:5220)
at org.apache.catalina.core.StandardContext
$2.call(StandardContext.java:5215)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)

I use javamelody 1.29.0. I need answer if it's even possible to do
this first ;] Maybe it's not and I waste my time. Thanks for your help
in advance.

Emeric Vernat

unread,
Jul 18, 2011, 5:45:42 AM7/18/11
to javam...@googlegroups.com
Hi,

It depends, and currently the answer for your case is no.

But first, what is your application server? why is there
com.sun.jndi.fscontext.RefFSContext in your jndi context?

For alternatives, do you use the DataSource via Spring? Do you use
hibernate?

bye,
Emeric


Le 18/07/2011 10:43, makikaze a �crit :

makikaze

unread,
Jul 18, 2011, 6:06:38 AM7/18/11
to javamelody
Hi,

I use Tomcat 7. I had to use own JNDI context because my datasources
are changing dynamically every day (update once a day). So I don't
register this datasources in Spring, and I don't use Hibernate or any
other ORM. Application executes stored procedures. Tomcat JNDI
registry is read-only so I've used fscontext and store JNDI bindings
on filesystem. If I would register these dynamically created
datasources in Spring (dynamically also) it would be working? I
haven't tried it yet. I know I don't like this dynamism too but it's
required though. I wanted only to monitor connection count to these
databases from the application. I could monitor it through the JMX
(C3P0 exposes PooledDataSource MBeans) but I've found javamelody which
looks very well.

Emeric Vernat

unread,
Jul 18, 2011, 8:22:27 PM7/18/11
to javam...@googlegroups.com
Hi,

It is a very specific use case and javamelody will not monitor those
datasources automatically.
I do not know exactly if it would work if you register these dynamically
in Spring.

I suggest to let javamelody skip its rebinding and that you use
net.bull.javamelody.JdbcWrapper.SINGLETON.createDataSourceProxy each
time that you create a ComboPooledDataSource.
You can then bind the result of this method in your fscontext.

You need the latest javamelody 1.30.0 for this, because JdbcWrapper was
not public before 1.30.0.

bye,
Emeric


Le 18/07/2011 12:06, makikaze a �crit :

Reply all
Reply to author
Forward
0 new messages