Good day!
There was a problem using a bunch of Java + Hibernate + JSP + Tomcat. When the project and MySQL database are located on the local computer, everything works perfectly. However, after transferring to the server, the following error occurs:
HTTP Status 500 - Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class ru.develop.test.utils.HibernateUtils java.lang.NoClassDefFoundError: Could not initialize class ru.develop.test.utils.HibernateUtils I read that this may be related to the static section of the HibernateUtils.java configuration file:
public class HibernateUtils { private static final SessionFactory sessionFactory; public HibernateUtils() { } static { try { sessionFactory = new Configuration().configure().buildSessionFactory(); } catch (Throwable e) { System.err.println("Initial SessionFactory creation failed." + e); throw new ExceptionInInitializerError(e); } } public static SessionFactory getSessionFactory() { return sessionFactory; } } Config:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <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://<мой хост>.ru:3306/dbname?autoReconnect=true</property> <property name="hibernate.connection.username">username</property> <property name="hibernate.connection.password">password</property>> <!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">1</property> <!-- Enable Hibernate's automatic session context management --> <property name="current_session_context_class">thread</property> <property name="hibernate.enable_lazy_load_no_trans">true</property> <!-- Disable the second-level cache --> <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> <!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property> <!-- Mapping files --> </session-factory> </hibernate-configuration> How can I overcome the problem?
Thank!