GlassFish equivalent to WebSphere's "shared libraries"
By alexismp on déc. 16, 2008
This blog has moved to alexismp.wordpress.com
Follow the link for the most up-to-date version of this blog entry.
With migration opportunities from other application servers to GlassFish popping up here and there, I was recently asked how to deal with WebSphere shared libraries in GlassFish.
Common Class Loader
GlassFish v2 has a well defined Class Loader hierarchy which identifies the common class loader as the proper way to deal with shared libraries. So to make a long story short, putting you libraries and other framework JARs in
domains/domain1/lib is all you need to do.
The person asking me the question had tried putting the libraries in
domains/domain1/lib/ext which triggered an interesting
ClassNotFoundError for core Java EE classes such as
javax.servlet.http.HttpServlet. Shing Wai Chan was quick to explain that
domains/domain1/lib/ext is part of
-Djava.ext.dirs which makes any of its JARs be considered as a JDK extension which means web app frameworks placed there will be loaded before webcontainer implementation classes as they are higher up in the classloader delegation chain.
Update: make sure you read the comments for additional suggestions from Sahoo and John.