JNDI JDBC monitoring

530 views
Skip to first unread message

Marc Lefevre

unread,
May 28, 2010, 1:47:45 AM5/28/10
to javamelody
Hi,

I try to setup a JNDI JDBC monitoring on Jboss with two data source.
But I have the following exception :

2010-05-28 07:15:27,969 179455 WARN
[org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker]
(QuartzScheduler_QuartzSchedulerThread:) Unexpected error in
pingDatabase
java.lang.IllegalArgumentException:
java.lang.ClassCastException@11a5dd9
at sun.reflect.GeneratedMethodAccessor113.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker.isValidConnection(OracleValidConnectionChecker.java:
68)
at
org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.isValidConnection(BaseWrapperManagedConnectionFactory.java:
458)
at
org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkValid(BaseWrapperManagedConnection.java:
322)
at
org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.matchManagedConnections(XAManagedConnectionFactory.java:
182)
at
org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:
213)
at org.jboss.resource.connectionmanager.JBossManagedConnectionPool
$BasePool.getConnection(JBossManagedConnectionPool.java:575)
at
org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:
347)
at
org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:
330)
at
org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:
402)
at
org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:
849)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:491)
at net.bull.javamelody.JdbcWrapper
$DelegatingInvocationHandler.invoke(JdbcWrapper.java:250)
at $Proxy313.allocateConnection(Unknown Source)
at
org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:
89)
at org.springframework.scheduling.quartz.LocalDataSourceJobStore
$2.getConnection(LocalDataSourceJobStore.java:125)
at
org.quartz.utils.DBConnectionManager.getConnection(DBConnectionManager.java:
112)
at
org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStoreCMT.java:
164)
at
org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:
3744)
at
org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:
2729)
at
org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:
266)


My datasource is

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<xa-datasource>
<jndi-name>jdbc/mydatasource</jndi-name>
<track-connection-by-tx>true</track-connection-by-tx>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>
oracle.jdbc.xa.client.OracleXADataSource
</xa-datasource-class>
<xa-datasource-property name="URL">
${ippproject.database.url}
</xa-datasource-property>
<xa-datasource-property name="User">
${ippproject.database.username}
</xa-datasource-property>
<xa-datasource-property name="Password">
${ippproject.database.password}
</xa-datasource-property>
<min-pool-size>5</min-pool-size>
<max-pool-size>50</max-pool-size>
<blocking-timeout-millis>10000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes><!-- Uses the
pingDatabase method to check a connection is still valid before
handing it out from the pool -->
<valid-connection-checker-class-name>
org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker
</valid-connection-checker-class-name><!-- Checks the Oracle error
codes and messages for fatal errors -->
<exception-sorter-class-name>
org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
</exception-sorter-class-name><!-- Oracles XA datasource cannot
reuse a connection outside a transaction once enlisted in a global
transaction and vice-versa -->
<no-tx-separate-pools />
</xa-datasource>
</datasources>

I suppose it is link to my vendor specific connection checker. How can
I solve this?
Thank you

Best regards
Marc

evernat

unread,
May 28, 2010, 12:42:23 PM5/28/10
to javamelody
Hi,

I found a version of the source file of OracleValidConnectionChecker:
http://www.docjar.com/html/api/org/jboss/resource/adapter/jdbc/vendor/OracleValidConnectionChecker.java.html

And this checker calls *with java.lang.reflect* the method
"pingDatabase" assuming that the parameter implementing the interface
java.sql.Connection is in fact of the class
oracle.jdbc.driver.OracleConnection.
And with JavaMelody this is not the case.

I would suggest to the author of OracleValidConnectionChecker.java
(Adrian Brock, adrian at jboss.org is given in the file) to replace
the line
Integer status = (Integer) ping.invoke(c, params);
with
Integer status = (Integer) ping.invoke(c.unwrap(Connection.class),
params);
if jboss is run inside a 1.6 jvm.

For reference,since Java 1.6, the Connection interface extends the
Wrapper interface with the unwrap method.
Javadoc: http://java.sun.com/javase/6/docs/api/java/sql/Wrapper.html#unwrap%28java.lang.Class%29

Otherwise this current OracleValidConnectionChecker is incompatible
with JavaMelody sql monitoring (you can disable all sql monitoring
with the context parameter "no-database" in javamelody).

If you want to keep JavaMelody, you should remove this
OracleValidConnectionChecker, and certainly you can put a non-vendor
specific check in JBoss datasource.
(something like a "check-valid-connection-sql" of value "select 1 from
dual" which will be called each time that a connection pool is checked
out from the connections pool, or if you want in background with
"background-validation").

The following document explains all this: http://community.jboss.org/wiki/configdatasources
Note: I do not know if the Oracle pingDatabase is better or not than
"select 1 from dual" for the performance.

Emeric

jean-pierre lerbscher

unread,
Jun 29, 2010, 8:32:03 AM6/29/10
to javamelody
Emeric,

Il semble que l'on puisse avoir ce type de problème lorsque les
librairies oracle sont déclarées dans les librairies du serveur et
dans l'application (problème de classloader).

@+

On 28 mai, 18:42, evernat <ever...@free.fr> wrote:
> Hi,
>
> I found a version of the source file of OracleValidConnectionChecker:http://www.docjar.com/html/api/org/jboss/resource/adapter/jdbc/vendor...
>
> And this checker calls *with java.lang.reflect* the method
> "pingDatabase" assuming that the parameter implementing the interface
> java.sql.Connection is in fact of the class
> oracle.jdbc.driver.OracleConnection.
> And with JavaMelody this is not the case.
>
> I would suggest to the author of OracleValidConnectionChecker.java
> (Adrian Brock, adrian at jboss.org is given in the file) to replace
> the line
> Integer status = (Integer) ping.invoke(c, params);
> with
> Integer status = (Integer) ping.invoke(c.unwrap(Connection.class),
> params);
> if jboss is run inside a 1.6 jvm.
>
> For reference,since Java 1.6, the Connection interface extends the
> Wrapper interface with the unwrap method.
> Javadoc:http://java.sun.com/javase/6/docs/api/java/sql/Wrapper.html#unwrap%28...
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp­l.java:
> > 25)
> >         at java.lang.reflect.Method.invoke(Method.java:597)
> >         at
> > org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker.isValid­Connection(OracleValidConnectionChecker.java:
> > 68)
> >         at
> > org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnectionFactory.isValid­Connection(BaseWrapperManagedConnectionFactory.java:
> > 458)
> >         at
> > org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkValid(Bas­eWrapperManagedConnection.java:
> > 322)
> >         at
> > org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.matchManagedC­onnections(XAManagedConnectionFactory.java:
> > 182)
> >         at
> > org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConne­ction(InternalManagedConnectionPool.java:
> > 213)
> >         at org.jboss.resource.connectionmanager.JBossManagedConnectionPool
> > $BasePool.getConnection(JBossManagedConnectionPool.java:575)
> >         at
> > org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConne­ction(BaseConnectionManager2.java:
> > 347)
> >         at
> > org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnecti­on(TxConnectionManager.java:
> > 330)
> >         at
> > org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnect­ion(BaseConnectionManager2.java:
> > 402)
> >         at
> > org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManag­erProxy.allocateConnection(BaseConnectionManager2.java:
> > 849)
> >         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >         at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > 39)
> >         at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp­l.java:
> > 25)
> >         at java.lang.reflect.Method.invoke(Method.java:597)
> >         at net.bull.javamelody.JdbcWrapper$3.invoke(JdbcWrapper.java:491)
> >         at net.bull.javamelody.JdbcWrapper
> > $DelegatingInvocationHandler.invoke(JdbcWrapper.java:250)
> >         at $Proxy313.allocateConnection(Unknown Source)
> >         at
> > org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperData­Source.java:
> > 89)
> >         at org.springframework.scheduling.quartz.LocalDataSourceJobStore
> > $2.getConnection(LocalDataSourceJobStore.java:125)
> >         at
> > org.quartz.utils.DBConnectionManager.getConnection(DBConnectionManager.java­:
> > 112)
> >         at
> > org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStore­CMT.java:
> > 164)
> >         at
> > org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobS­toreSupport.java:
> > 3744)
> >         at
> > org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSup­port.java:
> > Marc- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -
Reply all
Reply to author
Forward
0 new messages