I recently released version 2.0.0 of the ClassLoader Leak Prevention library to Maven Central. This is a major refactoring, that provides the following new.
App server and non-servlet framework integration
The library now has a core module that does not assume a servlet environment. This means that the library can be integrated into environments that do dynamic class loading, such as scripting enginges. It also means that Java EE application servers can integrate the library, so that web apps deployed onto that server wouldn’t need to include the library to be protected from java.lang.OutOfMemoryError: PermGen space / Metaspace
. More details can be found in the module README.md on GitHub
Zero-config Servlet 3.0+ module
If you’re in a Servlet 3.0 or 3.1 environment, there is no longer a need for explicitly declaring the <listener>
in web.xml
. Instead use a the classloader-leak-prevention-servlet3
Maven dependency that handles this for you automatically. For details, see the README.md on GitHub.
Preventions are now plugins
In version 1.x, you needed to subclass the librarys ServletContextListener
to add, remove or change behaviour of specific leak prevention measures. In 2.x, each prevention mechanism is a separate class implementing an interface. This makes it easier to implement your own additional preventions, remove measures from the configuration, or subclass and adjust any single mechanism.
Improved logging
While 1.x logged to System.out
/System.err
unless you subclassed and overrode the log methods, 2.x by default uses java.util.logging
(JUL). You can also easily switch to the System.out
/System.err
behaviour, or provide your own logging.
Please note that bridging JUL to other logging frameworks (for example using jul-to-slf4j has not been tested, and may produce unexpected results, in case something is logged after the logging framework has been shut down by the library.