title: Hibernate -- Exception sending context destroyed event to listener instance
body: <p>I have a configuration listener that creates a Hibernate session when a user hits the application.  I'm getting an error from the contextDestroyed method.  Can anyone help me with this?  Here is the method that's causing the problem.</p>
  
  <pre><code>public void contextDestroyed(ServletContextEvent arg0) {
      this.sessionFactory.close();
  }
  </code></pre>
  
  <p>Here are the error messages on my console.</p>
  
  <pre><code>SEVERE: Exception sending context initialized event to listener instance of class com.configuration.ConfigurationListener
  java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMap
      at org.hibernate.mapping.Table.&lt;init&gt;(Table.java:32)
      at org.hibernate.cfg.Mappings.addTable(Mappings.java:120)
      at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:251)
      at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:236)
      at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
      at org.hibernate.cfg.Configuration.add(Configuration.java:362)
      at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
      at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
      at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
      at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
      at com.configuration.ConfigurationListener.contextInitialized(ConfigurationListener.java:19)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
      at org.apache.catalina.core.StandardService.start(StandardService.java:516)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
  Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.SequencedHashMap
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
      ... 30 more
  Jun 25, 2012 5:21:59 PM org.apache.catalina.core.StandardContext start
  SEVERE: Error listenerStart
  Jun 25, 2012 5:21:59 PM org.apache.catalina.core.StandardContext start
  SEVERE: Context [/ghs1986] startup failed due to previous errors
  Jun 25, 2012 5:21:59 PM org.apache.catalina.core.StandardContext listenerStop
  SEVERE: Exception sending context destroyed event to listener instance of class com.configuration.ConfigurationListener
  java.lang.NullPointerException
      at com.configuration.ConfigurationListener.contextDestroyed(ConfigurationListener.java:25)
      at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3869)
      at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4503)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4367)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
      at org.apache.catalina.core.StandardService.start(StandardService.java:516)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
  </code></pre>