Java. lang. ExceptionInInitializerError (HIBERNATE problem)

Source: Internet
Author: User
This error occurs during the first running!

Exception

Javax. servlet. ServletException: Servlet execution threw an exception

Root cause

Java. lang. ExceptionInInitializerError
Classmate. HibernateUtil. <clinit> (HibernateUtil. java: 35)
Classmate. DbOperate. getUser (DbOperate. java: 25)
Classmate.LoginAction.exe cute (LoginAction. java: 27)
Org. apache. struts. action. RequestProcessor. processActionPerform (RequestProcessor. java: 419)
Org. apache. struts. action. RequestProcessor. process (RequestProcessor. java: 224)
Org. apache. struts. action. ActionServlet. process (ActionServlet. java: 1194)
Org. apache. struts. action. ActionServlet. doPost (ActionServlet. java: 432)
Javax. servlet. http. HttpServlet. service (HttpServlet. java: 709)
Javax. servlet. http. HttpServlet. service (HttpServlet. java: 802

The corresponding statement in the program is the THROW statement throw new ExceptionInInitializerError (ex );

The details are as follows:

Try {



SessionFactory = new Configuration (). configure (). buildSessionFactory ();


} Catch (Throwable ex ){
Ex. printStackTrace (); // TODO: handle exception
Throw new ExceptionInInitializerError (ex );
}

This error occurs during the second operation!

The above error only appears once!
Then this error always occurs!

Error message: Root cause

Java. lang. NoClassDefFoundError

The corresponding sentence in the program:

Session session = HibernateUtil. currentSession ();

Solution:

Put the JAR10 required packages of HIBERNATE

COPY to the LIB directory of the project
(If you build a path in JAVA, add the external JAR package, add the required packages, and COPY them to the LIB directory of the job !)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.