• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

instances of Class loaders ???

 
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Suppose I have a web server(say tomcat) and there are 3 web applications...then how many class loaders are present and how many JVMS...

Tx in advance,
Regards
 
Ranch Hand
Posts: 116
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One JVM.
The number of classloaders depends on the app (or web) server. For Tomcat there is one classloader per web app. A parent class loader of the web app classloaders is "shared" by all web apps. Above that are "common", "system" and "bootstrap". An additional "catalina" classloader is a child of "common". The JVM has at least one additional classloader and more likely three.
So if you have three webapps then you have at least 9 and probably more like 11 class loaders total.
In Tomcat the ones you probably care about are the webapp specific classloader and the "shared" classloader (for shared libraries). If you are writing realms, connectors or resources then you may also touch "common" and "catalina".
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Chris!!!

But how to get hold of the "shared" classloader??
[ April 10, 2007: Message edited by: A Kumar ]
 
Chris Beckey
Ranch Hand
Posts: 116
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you just need to load classes such that they are available to multiple webapps then put the classes/lib in the "shared" directory (i.e. C:\Program Files\Apache Software Foundation\Tomcat 5.5\shared on a Windows box with the default install).
If you really need a reference to the shared class loader you can get a reference to the webapp class loader (this.getClass().getClassLoader() from a servlet will do the trick) and then get its parent (getParent()).
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Chris!!!
 
reply
    Bookmark Topic Watch Topic
  • New Topic