diff --git a/pom.xml b/pom.xml
index 13040a701..c5bf6c955 100644
--- a/pom.xml
+++ b/pom.xml
@@ -163,7 +163,6 @@
ch.qos.logback
logback-classic
- runtime
diff --git a/src/main/java/org/springframework/samples/petclinic/util/CleanUp.java b/src/main/java/org/springframework/samples/petclinic/util/CleanUp.java
new file mode 100644
index 000000000..9e22cbaa0
--- /dev/null
+++ b/src/main/java/org/springframework/samples/petclinic/util/CleanUp.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.samples.petclinic.util;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.LoggerContext;
+
+/**
+ * When the web application stops, various resources need to be cleaned up to
+ * prevent memory leaks.
+ */
+public class CleanUp implements ServletContextListener {
+
+ @Override
+ public void contextInitialized(ServletContextEvent arg0) {
+ // NO-OP
+ }
+
+ @Override
+ public void contextDestroyed(ServletContextEvent arg0) {
+ // Logback is configured to use JMX so make sure that all objects are
+ // deregistered from JMX else there will be a memory leak
+ // http://logback.qos.ch/manual/jmxConfig.html
+ LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+ lc.stop();
+ }
+}
diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml
index ba2b51463..2dda4388a 100644
--- a/src/main/resources/logback.xml
+++ b/src/main/resources/logback.xml
@@ -8,7 +8,10 @@
+
+
+ PetClinic
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index ea965de25..2d7813935 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -1,118 +1,121 @@
-
-
-
- Spring PetClinic
- Spring PetClinic sample application
-
-
-
- spring.profiles.active
- jpa
-
-
-
-
-
-
-
-
-
-
-
- contextConfigLocation
- classpath:spring/business-config.xml, classpath:spring/tools-config.xml
-
-
-
- org.springframework.web.context.ContextLoaderListener
-
-
-
-
- petclinic
- org.springframework.web.servlet.DispatcherServlet
-
- contextConfigLocation
- classpath:spring/mvc-core-config.xml
-
- 1
-
-
-
- petclinic
- /
-
-
-
-
- dandelionServlet
- com.github.dandelion.core.web.DandelionServlet
- 2
-
-
- dandelionServlet
- /dandelion-assets/*
-
-
-
-
- encodingFilter
- org.springframework.web.filter.CharacterEncodingFilter
-
- encoding
- UTF-8
-
-
- forceEncoding
- true
-
-
-
-
- encodingFilter
- /*
-
-
-
-
- dandelionFilter
- com.github.dandelion.core.web.DandelionFilter
-
-
- dandelionFilter
- /*
-
-
-
-
- datatables
- com.github.dandelion.datatables.core.web.filter.DatatablesFilter
-
-
- datatables
- /*
-
-
-
-
-
+
+
+
+ Spring PetClinic
+ Spring PetClinic sample application
+
+
+
+ spring.profiles.active
+ jpa
+
+
+
+
+
+
+
+
+
+
+
+ contextConfigLocation
+ classpath:spring/business-config.xml, classpath:spring/tools-config.xml
+
+
+
+ org.springframework.web.context.ContextLoaderListener
+
+
+
+ org.springframework.samples.petclinic.util.CleanUp
+
+
+
+ petclinic
+ org.springframework.web.servlet.DispatcherServlet
+
+ contextConfigLocation
+ classpath:spring/mvc-core-config.xml
+
+ 1
+
+
+
+ petclinic
+ /
+
+
+
+
+ dandelionServlet
+ com.github.dandelion.core.web.DandelionServlet
+ 2
+
+
+ dandelionServlet
+ /dandelion-assets/*
+
+
+
+
+ encodingFilter
+ org.springframework.web.filter.CharacterEncodingFilter
+
+ encoding
+ UTF-8
+
+
+ forceEncoding
+ true
+
+
+
+
+ encodingFilter
+ /*
+
+
+
+
+ dandelionFilter
+ com.github.dandelion.core.web.DandelionFilter
+
+
+ dandelionFilter
+ /*
+
+
+
+
+ datatables
+ com.github.dandelion.datatables.core.web.filter.DatatablesFilter
+
+
+ datatables
+ /*
+
+
+
+
+