错误:java.lang.NoClassDefFoundError:无法初始化类Util.HibernateUtil

时间:2018-06-13 00:58:03

标签: java hibernate jsp servlets java-web-start

我尝试这样做时遇到此错误:

package Util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


public class HibernateUtil {

    private static final SessionFactory sessionFactory;

    static {
            try { 
                    Configuration cfg = new Configuration();
                    cfg.configure("hibernate.cfg.xml");
                    sessionFactory = cfg.buildSessionFactory();

                } catch (Throwable ex) {
                    // Log the exception. 
                    System.err.println("Initial SessionFactory creation failed." + ex);
                    throw new ExceptionInInitializerError(ex);
                }
            }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }
}

Hibernate属性为:

<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/educampo</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.current_session_context_class">jta</property>

<mapping class="Classes/TblSolicitacaocadastro"/>

0 个答案:

没有答案