Hibernate "PreInsertEvent.getSource()" NoSuchMethodError

10,312

Solution 1

I found a solution, but I'm not sure it's correct -- anyone with a better, please advise:

Added a reference to cglib, and explicity excluded hibernate (was including 3.2)

 <dependencies>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>3.4.0.GA</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>3.3.0.ga</version>
        <exclusions>
            <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.3.1.GA</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>3.1.0.GA</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.4.0.GA</version>
    </dependency>

    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.1</version>
    </dependency>
</dependencies>

Solution 2

This is a known bug : https://hibernate.onjira.com/browse/HVAL-81 . It occurs when you reference an older version of hibernate validator than core.

Share:
10,312
Marty Pitt
Author by

Marty Pitt

Updated on June 17, 2022

Comments

  • Marty Pitt
    Marty Pitt almost 2 years

    I'm recieving the following error when trying to do inserts:

    java.lang.NoSuchMethodError : org.hibernate.event.PreInsertEvent.getSource()Lorg/hibernate/event/EventSource;

    I've seen other people with the same problem due to incompatibility in hibernate jars, but I believe I've got it right (according to the compatibility matrix)

    Here's the relevant section from my pom.xml:

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-annotations</artifactId>
            <version>3.4.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
            <version>3.3.0.ga</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.3.1.GA</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>3.1.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.4.0.GA</version>
        </dependency>
    

    Can anyone advise?

    Regards

    Marty

  • Hosam Aly
    Hosam Aly over 14 years
    I am not using Maven, but I added all the latest dependencies by hand and it worked.
  • raksja
    raksja over 11 years
    This is just a duplicate, look in the original bug HVAL-75 for more information/status.