java.lang.NoClassDefFoundError: Could not initialize class org.com.hibernate.HibernateUtil

后端 未结 4 1341
一向
一向 2021-01-24 08:18

This is my hibernate util code

public class HibernateUtil {

private static final SessionFactory sessionFactory = buildSessionFactory();

private static SessionF         


        
相关标签:
4条回答
  • 2021-01-24 08:32

    use this jar:::

    antlr-2.7.7
    commons-collections-3.2.1
    dom4j-1.6.1
    hibernate-commons-annotations-4.0.1.Final
    hibernate-core-4.1.9.Final
    hibernate-entitymanager-4.1.9.Final
    hibernate-jpa-2.0-api-1.0.1.Final
    javassist-3.17.1-GA
    jboss-transaction-api_1.1_spec-1.0.0.Final
    jboss-logging-3.1.0.GA
    sqljdbc4-2.0(as per your database used)
    

    found from:

    http://sourceforge.net/projects/hibernate/files/latest/download?source=files

    0 讨论(0)
  • 2021-01-24 08:34

    You can download jars related to hibernate at

    http://sourceforge.net/projects/hibernate/files/hibernate3

    unzip it and check whether the following files are added to your lib folder

    Anttr-2.7.6.jar
    asm.jar
    asm-attrs.jar
    cglib-2.1.3.jar
    commons-collections-2.1.1.jar
    commons-logging-1.0.4.jar
    ehcash.jar
    dom4j-1.6.1.jar
    hibernate3.jar    <--Check this version of your jar
    jta.jar
    log4j-1.2.3.jar
    

    To run hibernate related programming and among all the jars hibernate3.jar is the main file..

    Along with the hibernate jars you must include one more jar file related to the type of database(mysql,oracle,etc..) you use..

    Try using proper versions of jar before you execute your program...some versions of jars are not supported to run...and the latest one is recommended...

    0 讨论(0)
  • 2021-01-24 08:40

    You haven't provided the package name in your HibernateUtil class. If no package is defined the class will belong to default package and you cannot get the HibernateUtil class from org.com.hibernate.HibernateUtil

    0 讨论(0)
  • 2021-01-24 08:52

    If someone is facing the same problem who are using Glassfish server you have to do the following,

    1. Go your Glassfish installation path and add your database's jdbc driver under the path glassfish/domains/domain1/lib/

    2. Restart your Glassfish server.

    0 讨论(0)
提交回复
热议问题