Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Hibernate: ClassDefNotFoundError

 
Ranch Hand
Posts: 32
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
     
    author & internet detective
    Posts: 40912
    840
    Eclipse IDE VI Editor Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
    Netbeans IDE Oracle Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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:
     
    Ranch Hand
    Posts: 180
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Try calling session.saveOrUpdate() after course.setCourseName()
     
    ali honarmand
    Ranch Hand
    Posts: 32
    Netbeans IDE Oracle Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
    reply
      Bookmark Topic Watch Topic
    • New Topic