How can I cache server-wide (with cache scope spanning multiple WARs on this server) instances of classes from a JAR which is contained binary-identical in several WARs on a web container (server, e. g. Tomcat)?
<EDIT> I want to cache application data across WARs because the data is common to them. (It's a portal project, where it can be useful to share common data across different "views" implemented as different portlets deployed as different WARs, and using a Java object cache is much faster and more simple than using a central data-holding service.) </EDIT>
Is that possible at all? Or is it required to put such a JAR on a path accessed by a common parent classloader, like in /lib/ext ?
See: Java, Classpath, Classloading => Multiple Versions of the same jar/project
See: How does class loading work when the same class exists in different applications on the same server?
Yes, the best option is to put the classes in a class loader that is a parent of the two applications. If by
lib/extyou meanJAVA_HOME/lib/ext, then I would not recommend that. Instead, you should put them inCATALINA_HOME/libdirectory. See the Shared Library Files section of the documentation, which links to the Class Loader HOW-TO documentation.