Martin Dvoracek
Martin Dvoracek

Reputation: 1738

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?

Upvotes: 6

Views: 17236

Answers (3)

Evgeniy Dorofeev
Evgeniy Dorofeev

Reputation: 135992

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

Upvotes: 5

Koty
Koty

Reputation: 11

  <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.2.0.Final</version>
    </dependency>        
    <dependency>
        <groupId>org.hibernate.common</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>4.0.1.Final</version>
        <classifier>tests</classifier>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.1.Final</version>
    </dependency>      
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.0.1.Final</version>
    </dependency>       
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.4</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.1.0.CR2</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.4</version>
    </dependency>

Upvotes: 1

Himanshu Bhardwaj
Himanshu Bhardwaj

Reputation: 4113

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.

Upvotes: 1

Related Questions