ArrayIndexOutOfBoundsException when using javamelody.HibernateBatcherFactory

182 views
Skip to first unread message

Bart

unread,
Apr 28, 2011, 7:51:58 AM4/28/11
to javamelody
I added javamelody 1.26 to my application , which succeeded partially.
It actually works for queries but crashes my app when writing to the
DB.
It's a spring MVC application(httpinvoker) running on jboss 4.0.5
running on java 1.5.0_20 . The database is sqlserver 2000.
I added
- The MonitoringFilter in web.xml, filtering all.
- the datasource name in the datasources prop of the
net.bull.javamelody.MonitoringFilter.
- classpath:net/bull/javamelody/monitoring-spring.xml as first to
contextConfigLocation
- hibernate property hibernate.jdbc.factory_class :
net.bull.javamelody.HibernateBatcherFactory
- @net.bull.javamelody.MonitoredWithSpring to the classes I want to
monitor

As said the sql and spring monitoring works but I can't see e.g. the
connections, under the graghs there's a lot of NaN.
When the app writes to the DB, the values are saved but I get an
ArrayIndexOutOfBoundsException at
org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:
32 ).
When I remove the hibernate property hibernate.jdbc.factory_class :
net.bull.javamelody.HibernateBatcherFactory, there's no error but also
no sql monitoring.

Further there are a couple of loggings when the app is deployed, a lot
of "Unable to proxy method" and "Bean '...' is not eligible for
getting processed by all BeanPostProcessors"

Any ideas ?

Bart

Emeric Vernat

unread,
Apr 29, 2011, 6:50:53 PM4/29/11
to javam...@googlegroups.com
Hi,

Which version of hibernate do you use?
Can you post a more complete stack-trace of the
ArrayIndexOutOfBoundsException?

Do you use your datasource via Spring and by defining it in the spring
xml context perhaps? If yes, have you tried to monitor this datasource
in Spring and not with javamelody's HibernateBatcherFactory?
See http://code.google.com/p/javamelody/wiki/UserGuide?tm=6#7._JDBC
(Note that SpringDataSourceFactoryBean was added in javamelody 1.27 and
is not available in javamelody 1.26)

Thanks,
Emeric


Le 28/04/2011 13:51, Bart a �crit :

Bart

unread,
May 2, 2011, 4:57:35 AM5/2/11
to javamelody
I retried without the HibernateBatcherFactory and with debugging level
set. In the startup I get this logging :

(mainhread) 02/05/11 10:45:11 DEBUG [javamelody] datasources found in
JNDI: [java:finatmed]
(mainhread) 02/05/11 10:45:11 DEBUG [javamelody] rebinding datasources
failed, skipping
java.lang.ClassNotFoundException:
org.apache.naming.ContextAccessController
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1355)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:
1201)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at
net.bull.javamelody.JdbcWrapperHelper.changeContextWritable(JdbcWrapperHelper.java:
159)
at
net.bull.javamelody.JdbcWrapperHelper.rebindDataSource(JdbcWrapperHelper.java:
55)
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)
.....

So my datasource is found but then something goes wrong.
There's no connection or sql monitoring now , my DB is shown in the
system properties.

Thanks for replying (forgot that in my previous post),

Bart

On Apr 30, 12:50 am, Emeric Vernat <ever...@free.fr> wrote:
> Hi,
>
> Which version of hibernate do you use?
> Can you post a more complete stack-trace of the
> ArrayIndexOutOfBoundsException?
>
> Do you use your datasource via Spring and by defining it in the spring
> xml context perhaps? If yes, have you tried to monitor this datasource
> in Spring and not with javamelody's HibernateBatcherFactory?
> Seehttp://code.google.com/p/javamelody/wiki/UserGuide?tm=6#7._JDBC

Philip Zeyliger

unread,
May 2, 2011, 4:58:58 PM5/2/11
to javam...@googlegroups.com
Hi Bart,

I'm experiencing similar behavior, and I filed http://code.google.com/p/javamelody/issues/detail?id=107&colspec=ID%20Type%20Status%20Priority%20Owner%20Summary yesterday.  To my naive reading of the source code, it looks like an if/else block is swapped logically.  If I enable the jdbc batc size parameter in Hibernate, all works as expected.

I haven't tried to rebuild JavaMelody with the if/else swapped quite yet.

-- Philip

Emeric Vernat

unread,
May 2, 2011, 5:59:34 PM5/2/11
to javam...@googlegroups.com
Hi,

It was a silly mistake in HibernateBatcherFactory. And I have changed the code to reverse the "if" and it should work now.
It is committed in trunk and it is ready for the next release (1.29).
I have made a new build from the current trunk including the fix and, if you want to try it, it is available at:
http://javamelody.googlecode.com/files/javamelody-20110502.jar

Please let us know if you verify the fix with this build or with the next release.

@Bart:
By the way, for the log below saying "rebinding datasources failed, skipping
ClassNotFoundException: org.apache.naming.ContextAccessController", it is just a log and it does not stop the monitoring.
The cause of that log seems to be that in your JBoss 4.0.5, the server does not name itself "JBoss" (but probably "Tomcat") as you can also read yourself on the "Server" line in the "System informations" part of the report. And so javamelody tries to monitor your datasource as in Tomcat, and failing to that, javamelody just skips the monitoring of your datasource.

Thanks,
Emeric

Bart

unread,
May 3, 2011, 6:42:15 AM5/3/11
to javamelody
OK, it works with javamelody-20110502.jar. I still have a lot of NaN
in the graphs and the datasource error log is still there but I'll try
to change the server name and open another forum thread if necessary.

Thanks a lot for the replies and the quick fix of the problem.

Bart

On May 2, 11:59 pm, Emeric Vernat <ever...@free.fr> wrote:
> Hi,
>
> It was a silly mistake in HibernateBatcherFactory. And I have changed
> the code to reverse the "if" and it should work now.
> It is committed in trunk and it is ready for the next release (1.29).
> I have made a new build from the current trunk including the fix and, if
> you want to try it, it is available at:http://javamelody.googlecode.com/files/javamelody-20110502.jar
>
> Please let us know if you verify the fix with this build or with the
> next release.
>
> @Bart:
> By the way, for the log below saying "rebinding datasources failed, skipping
> ClassNotFoundException: org.apache.naming.ContextAccessController", it
> is just a log and it does not stop the monitoring.
> The cause of that log seems to be that in your JBoss 4.0.5, the server
> does not name itself "JBoss" (but probably "Tomcat") as you can also
> read yourself on the "Server" line in the "System informations" part of
> the report. And so javamelody tries to monitor your datasource as in
> Tomcat, and failing to that, javamelody just skips the monitoring of
> your datasource.
>
> Thanks,
> Emeric
>
> Le 02/05/2011 22:58, Philip Zeyliger a �crit :
>
> > Hi Bart,
>
> > I'm experiencing similar behavior, and I filed
> >http://code.google.com/p/javamelody/issues/detail?id=107&colspec=ID%2...
> > <http://code.google.com/p/javamelody/issues/detail?id=107&colspec=ID%2...> yesterday.
> >  To my naive reading of the source code, it looks like an if/else
> > block is swapped logically.  If I enable the jdbc batc size parameter
> > in Hibernate, all works as expected.
>
> > I haven't tried to rebuild JavaMelody with the if/else swapped quite yet.
>
> > -- Philip
>

Bart

unread,
May 3, 2011, 9:47:43 AM5/3/11
to javamelody
For info: the empty graphs and NaN values are due to my browser,
firefox 3.6.16. It works fine in IE.

Bart

On May 2, 11:59 pm, Emeric Vernat <ever...@free.fr> wrote:
> Hi,
>
> It was a silly mistake in HibernateBatcherFactory. And I have changed
> the code to reverse the "if" and it should work now.
> It is committed in trunk and it is ready for the next release (1.29).
> I have made a new build from the current trunk including the fix and, if
> you want to try it, it is available at:http://javamelody.googlecode.com/files/javamelody-20110502.jar
>
> Please let us know if you verify the fix with this build or with the
> next release.
>
> @Bart:
> By the way, for the log below saying "rebinding datasources failed, skipping
> ClassNotFoundException: org.apache.naming.ContextAccessController", it
> is just a log and it does not stop the monitoring.
> The cause of that log seems to be that in your JBoss 4.0.5, the server
> does not name itself "JBoss" (but probably "Tomcat") as you can also
> read yourself on the "Server" line in the "System informations" part of
> the report. And so javamelody tries to monitor your datasource as in
> Tomcat, and failing to that, javamelody just skips the monitoring of
> your datasource.
>
> Thanks,
> Emeric
>
> Le 02/05/2011 22:58, Philip Zeyliger a �crit :
>
> > Hi Bart,
>
> > I'm experiencing similar behavior, and I filed
> >http://code.google.com/p/javamelody/issues/detail?id=107&colspec=ID%2...
> > <http://code.google.com/p/javamelody/issues/detail?id=107&colspec=ID%2...> yesterday.
> >  To my naive reading of the source code, it looks like an if/else
> > block is swapped logically.  If I enable the jdbc batc size parameter
> > in Hibernate, all works as expected.
>
> > I haven't tried to rebuild JavaMelody with the if/else swapped quite yet.
>
> > -- Philip
>

Emeric Vernat

unread,
May 7, 2011, 3:56:32 PM5/7/11
to javam...@googlegroups.com
Hi,

Are you sure that you used the same period in firefox and in IE?
It is a fact that the period is stored in a cookie on the client and is
persisted across browser restarts.
So it may explain that you used different periods depending on the
browser and so the NaN values in the graphics.

To sum up, if you have NaN values in the graphics:
- check the period displayed (the day period has values before the year
period)
- be sure that your server is used enough on a regular basis
- wait one day to have more values

bye, Emeric


Le 03/05/2011 15:47, Bart a �crit :


> For info: the empty graphs and NaN values are due to my browser,
> firefox 3.6.16. It works fine in IE.
>
> Bart
>
> On May 2, 11:59 pm, Emeric Vernat<ever...@free.fr> wrote:
>> Hi,
>>
>> It was a silly mistake in HibernateBatcherFactory. And I have changed
>> the code to reverse the "if" and it should work now.
>> It is committed in trunk and it is ready for the next release (1.29).
>> I have made a new build from the current trunk including the fix and, if
>> you want to try it, it is available at:http://javamelody.googlecode.com/files/javamelody-20110502.jar
>>
>> Please let us know if you verify the fix with this build or with the
>> next release.
>>
>> @Bart:
>> By the way, for the log below saying "rebinding datasources failed, skipping
>> ClassNotFoundException: org.apache.naming.ContextAccessController", it
>> is just a log and it does not stop the monitoring.
>> The cause of that log seems to be that in your JBoss 4.0.5, the server
>> does not name itself "JBoss" (but probably "Tomcat") as you can also
>> read yourself on the "Server" line in the "System informations" part of
>> the report. And so javamelody tries to monitor your datasource as in
>> Tomcat, and failing to that, javamelody just skips the monitoring of
>> your datasource.
>>
>> Thanks,
>> Emeric
>>

>> Le 02/05/2011 22:58, Philip Zeyliger a �crit :

Reply all
Reply to author
Forward
0 new messages