• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate: ClassDefNotFoundError

 
ali honarmand
Ranch Hand
Posts: 32
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm a new hibernate user and I have got the following problem:

I have referenced the class:
  • org.hibernate.cfg.Configuration

  • and the whole bundle and use the class as follows:

    but face the following Exception:
    Initial SessionFactory creation failed.class java.lang.NoClassDefFoundError
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.vaannila.util.HibernateUtil.<clinit>(HibernateUtil.java:19)
    at com.vaannila.course.Main.saveCourse(Main.java:35)
    at com.vaannila.course.Main.main(Main.java:25)
    Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException
    at com.vaannila.util.HibernateUtil.<clinit>(HibernateUtil.java:13)
    ... 2 more
    Although I have the class as a library in my project. please help.
    thanks
     
    Jeanne Boyarsky
    author & internet detective
    Marshal
    Posts: 34860
    369
    Eclipse IDE Java VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ali,
    Are you sure dom4j is in your runtime classpath? Some tools make this a little tricky so sharing what tool you are using/why you think it is in the classpath would help figure out why it isn't.
     
    ali honarmand
    Ranch Hand
    Posts: 32
    Java Netbeans IDE Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Jeanne Boyarsky wrote:Ali,
    Are you sure dom4j is in your runtime classpath? Some tools make this a little tricky so sharing what tool you are using/why you think it is in the classpath would help figure out why it isn't.

    thanks Jeanne,
    It was the dom4j problem and some other configuration issues.

    Now I have got a new problem with transaction.commit(). It throws an exception and quits. I should say that no update or delete commands work properly.
    can you help me with this issue please? Here is the exception:


    It happens for update while for insert no exception is thrown.
    Code for insert:

    code for update:
     
    Ogeh Ikem
    Ranch Hand
    Posts: 180
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Try calling session.saveOrUpdate() after course.setCourseName()
     
    ali honarmand
    Ranch Hand
    Posts: 32
    Java Netbeans IDE Oracle
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    ali honarmand wrote:
    Jeanne Boyarsky wrote:Ali,
    Are you sure dom4j is in your runtime classpath? Some tools make this a little tricky so sharing what tool you are using/why you think it is in the classpath would help figure out why it isn't.

    thanks Jeanne,
    It was the dom4j problem and some other configuration issues.

    Now I have got a new problem with transaction.commit(). It throws an exception and quits. I should say that no update or delete commands work properly.
    can you help me with this issue please? Here is the exception:


    It happens for update while for insert no exception is thrown.
    Code for insert:

    code for update:


    Wow, I did not begin() the transaction. thanks everyone.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic