Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure pom.xml for hibernate 3.6

I've tried to configure pom.xml file for my Spring 3 and Hibernate 3.6 application. The relevant part of pom.xml looks like this:

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.9</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.6.3.Final</version>
    </dependency>
    <dependency>
        <groupId>org.javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.17.1-GA</version>
    </dependency>
    <dependency>
        <groupId>asm</groupId>
        <artifactId>asm-all</artifactId>
        <version>2.2</version>
    </dependency>
    <dependency>
        <groupId>antlr</groupId>
        <artifactId>antlr</artifactId>
        <version>2.7.7</version>
    </dependency>

Nevertheless, if I don't include javassist.jar library directly to my buildpath as an External jar, I keep getting java.lang.ClassNotFoundException. Is there anything wrong in my pom.xml, due it doesn't download this dependency when building the project?

like image 545
Martin Dvoracek Avatar asked May 03 '13 07:05

Martin Dvoracek


2 Answers

Try hibernate-entitymanager instead of hibernate-core.

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>3.6.3.Final</version>
</dependency>

This will include all necessary dependencies transitively. Check maven dependency hierarchy after you make this change.

BTW the lastest available version of hibernate in maven central is 4.1.18

like image 187
Evgeniy Dorofeev Avatar answered Oct 02 '22 20:10

Evgeniy Dorofeev


java.lang.ClassNotFoundException should also mention the name of class which was not found.

  1. First you verify the jar you are trying to copy is getting copied into the build path or not.

  2. If 1 is yes, then expand the javassist-3.17.1-GA.jar to check if the missing class file for which you got exception is present or not.

The external jar which resolves the issues, try to find out its version, maybe you can get it from MANIFEST.MF file of that jar.

May be something was refactored which is causing the problem.

like image 31
Himanshu Bhardwaj Avatar answered Oct 02 '22 21:10

Himanshu Bhardwaj