1

ユーザーがアプリケーションにアクセスしたときにHibernateセッションを作成する構成リスナーがあります。contextDestroyedメソッドからエラーが発生します。誰かがこれを手伝ってくれますか?これが問題の原因となっている方法です。

public void contextDestroyed(ServletContextEvent arg0) {
    this.sessionFactory.close();
}

これが私のコンソールのエラーメッセージです。

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.<init>(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)
4

1 に答える 1

3

主な問題はcontextDestroy方法ではありません。問題はクラスパスにあります。クラスパスにapache commons collections jar がありません。Hibernate はそれに依存し、失敗します

java.lang.ClassNotFoundException: org.apache.commons.collections.SequencedHashMap.

これにより、後でリスナーのcontextDestoryedメソッドが呼び出されます。そのメソッドは、close()そのsessionFactory. しかしsessionFactory、前述のClassNotFoundException.

それはすべて、貼り付けられたコンソール ログに書き込まれます。

于 2012-06-26T01:29:29.963 に答える