2

私の問題は、ANT ビルド (正常にビルド) を介してアプリケーションを実行すると、ビルド フォルダーに必要なすべての jar を追加しても、次の実行時エラーが発生することです。私のビルド フォルダの添付ファイルを参照してください。

05:49:00,562 ERROR [DispatchAction] Dispatch[/loginUser] to method 'userLogin' returned an exception

06:01:49,656 ERROR [[action]] Servlet.service() for servlet action threw exception
java.lang.ExceptionInInitializerError
    at com.SupportLMS.dbutils.HibernateUtil.buildSessionFactory(HibernateUtil.java:18)
    at com.SupportLMS.dbutils.HibernateUtil.<clinit>(HibernateUtil.java:8)
    at com.SupportLMS.daoImpl.CommonDAOImpl.isValidUser(CommonDAOImpl.java:23)
    at com.SupportLMS.actions.HomeAction.userLogin(HomeAction.java:29)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:276)
    at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:196)
    at com.SupportLMS.commons.BaseAction.execute(BaseAction.java:20)
    at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
    at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
    at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:166)
    at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:175)
    at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:166)
    at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:831)
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:639)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1196)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/jboss/web/tomcat/tc5/WebAppClassLoader) previously initiated loading for a different type with name "org/hibernate/cfg/Configuration"
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1812)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:866)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1319)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at com.SupportLMS.dbutils.HibernateUtil.buildSessionFactory(HibernateUtil.java:14)
    ... 39 more

構成が間違っているとは思いませんが、私の構成ファイルは以下のとおりです。

    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.url">jdbc:mysql://localhost:3306/SupportLMS</property>
    <property name="connection.username">root</property>
    <property name="connection.password">admin</property>

    <!-- JDBC connection pool (use the built-in) -->
    <property name="connection.pool_size">1</property>

    <!-- SQL dialect -->
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

     <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">true</property>

    <property name="hbm2ddl.auto">update</property>

     <!-- Mapping files -->
    <mapping class="com.SupportLMS.model.SupportUsers" />

これが私の HibernateUtil.java ファイルです。

package com.SupportLMS.dbutils;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtil {

    private static final SessionFactory sessionFactory = buildSessionFactory();

    private static SessionFactory buildSessionFactory() {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            System.out.println("session start ");
            return new AnnotationConfiguration().configure()
                    .buildSessionFactory();
        } catch (Throwable ex) {
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
    System.out.println("sesion factory is   "+sessionFactory);
        return sessionFactory;
    }
}

SessionFactory が null を返すことに気付きました。クラックする方法がわかりません。

4

0 に答える 0