lemonzone2010 / javamelody

Automatically exported from code.google.com/p/javamelody
0 stars 0 forks source link

Ehcache 2.7.0 doesn't work with javamelody 1.43.0 #293

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. java j2ee project(no Spring and Hibernate)
2. This web container includes Ehcache(2.7.0) & javamelody 1.43.0 libraries.
3. when I call the Ehcache get cache method, the javamelody throws the 
exception information below.

What is the expected output? What do you see instead?
can normally use javamelody.

What version of the product are you using? On what application server, JDK,
operating system? Windows 7
App Server: Tomcat
javamelody version: 1.43.0

Please provide any additional information below.

SEVERE: Servlet.service() for servlet [default] in context with path 
[/myProject] threw exception [Filter execution threw an exception] with root 
cause
java.lang.NoSuchMethodError: 
net.sf.ehcache.Ehcache.getStatistics()Lnet/sf/ehcache/Statistics;
    at net.bull.javamelody.CacheInformations.<init>(CacheInformations.java:59)
    at net.bull.javamelody.CacheInformations.buildCacheInformationsList(CacheInformations.java:165)
    at net.bull.javamelody.JavaInformations.<init>(JavaInformations.java:188)
    at net.bull.javamelody.MonitoringController.doActionIfNeededAndReport(MonitoringController.java:136)
    at net.bull.javamelody.MonitoringFilter.doMonitoring(MonitoringFilter.java:340)
    at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:170)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.zyxel.template.model.filters.ActionHandler.doFilter(ActionHandler.java:43)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at com.jamonapi.http.JAMonTomcatValve.invoke(JAMonTomcatValve.java:72)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

Original issue reported on code.google.com by enzo...@gmail.com on 15 Mar 2013 at 2:39

GoogleCodeExporter commented 9 years ago
Just for reference, in ehcache v2.7 the following method does not exists as 
before, it now returns a new type (StatisticsGateway):
Statistics net.sf.ehcache.Ehcache.getStatistics()

The documentation of ehcache gives names of methods which just don't exists (I 
may ask myself why I have tried to read this documentation):
http://ehcache.org/documentation/code-samples#obtaining-statistics-of-cache-hits
-and-misses

The current displayed javadoc is not for the latest version, but for a previous 
version:
http://ehcache.org/apidocs/

Of course, the release notes says nothing about this change:
http://www.terracotta.org/confluence/display/release/Ehcache+2.7.0+Release+Notes

We will need to read the source of the 
net.sf.ehcache.management.CacheStatistics class (v2.7, attached) in order to 
understand how all the methods were renamed in the v2.7 API.
Cool, it was almost easy after all.

Note that the code to change is CacheInformations.java:
https://code.google.com/p/javamelody/source/browse/trunk/javamelody-core/src/mai
n/java/net/bull/javamelody/CacheInformations.java

Original comment by evernat@free.fr on 17 Mar 2013 at 9:18

Attachments:

GoogleCodeExporter commented 9 years ago
It is now fixed in current trunk (revision 3333) and ready for the next release 
in about a week (1.44).

I have made a new build from the current trunk and it is available at:
http://javamelody.googlecode.com/files/javamelody-20130324.jar

Note that because of the bug https://jira.terracotta.org/jira/browse/EHC-1010, 
the value of the efficiency (hits/access) displayed by javamelody is incorrect 
when using ehcache 2.7.0. It is not planned to work around this ehcache 2.7.0 
bug in javamelody.

Original comment by evernat@free.fr on 24 Mar 2013 at 3:55