5

I'm using JAMon, and I want to use the jamon.war to monitor my app. However, my app and the jamon.war app have different classloaders, and therefore they don't see each other's static variables (where the data is stored, as far as I understand). I am getting the proper data when I call MonitorFactory.getReport() in my app.

How to get this working?

Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140

1 Answers1

4

The problem was that I had jamon-xx.jar in my WEB-INF/lib. When I remove it (and have it only in tomcat's lib dir), it is loaded by the tomcat classloader (which I guess is a parent of all application classloaders), and so the two applications can share the static fields.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • Right, if you share a jar between different applications, you should do it through the tomcat/lib directory. Each webapp has in fact its own classloader, but you can put them in communication through the Common classloader. Have a look [here](http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html). – javanna Dec 08 '11 at 13:21
  • You can observe the same problem with EhCache shared `CacheManager` (the same manager for all WARs in Tomcat) - if the `ehcache.jar` is bundled with each application, each one will have its own `CacheManager` since EhCache uses `static` field to share manager... Once `ehcache.jar` is placed in `/lib` directory both application share the same `CacheManager` and caches. – Tomasz Nurkiewicz Dec 08 '11 at 13:36