aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate: ClassDefNotFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate: ClassDefNotFoundError" Watch "Hibernate: ClassDefNotFoundError" New topic
Author

Hibernate: ClassDefNotFoundError

ali honarmand
Ranch Hand

Joined: Oct 12, 2009
Posts: 32

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


    A. Honarmand
    Jeanne Boyarsky
    author & internet detective
    Marshal

    Joined: May 26, 2003
    Posts: 30780
        
    157

    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.


    [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
    Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
    ali honarmand
    Ranch Hand

    Joined: Oct 12, 2009
    Posts: 32

    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

    Joined: May 13, 2002
    Posts: 180
    Try calling session.saveOrUpdate() after course.setCourseName()
    ali honarmand
    Ranch Hand

    Joined: Oct 12, 2009
    Posts: 32

    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.
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Hibernate: ClassDefNotFoundError