Fixing issue with Classloader leaks.

We had an issue with a classloader leak. There were three things we had to do before it worked.

  1. Made the mysql connector provided and add mysql-connector jar to the tomcat/libexe/lib directory
    1. Maven block:
      <scope>provided test</scope>
  2. Added the following jvm option to use G1 garbage collection, and enable class unloading and perm gen sweep.
    NOTE: You need all three for this to work. Ignore the warning from java: “Please use CMSClassUnloadingEnabled in place of CMSPermGenSweepingEnabled in the future.” I’ve tried just G1, G1 with class unload, and G1 with perm gen. They are all needed for heap to stay low and for classes to be unloaded.

    -XX:+UseG1GC -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled
  3. Added the following library for classloader leak prevention.
    1. Add the following block in your pom.xml of the web module:
    2. Add the following listener to your web.xml:

Once that is all setup, do a clean package on maven, redeploy and restart tomcat