hibernate3-maven-plugin dependencies for newer version of hibernate
Asked Answered
O

5

5

I would like to use hibernate-3.5-1.Final along with this plugin, what should be my dependencies here. It seems to be picking up a older set of jars and failing right now.

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.2</version>
            </plugin>

EDIT1:

[INFO] class org.hibernate.cfg.ExtendedMappings has interface org.hibernate
.cfg.Mappings as super class
[INFO] --------------------------------------------------------------------
----
[INFO] Trace
java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMap
pings has interface org.hibernate.cfg.Mappings as super class
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.ja
va:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmC
lassLoader.java:195)
        at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClas
sRealm.java:255)
        at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLo
ader.java:214)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings
(AnnotationConfiguration.java:187)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(Anno
tationConfiguration.java:277)
        at org.hibernate.cfg.Configuration.buildMappings(Configuration.java
:1206)
        at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configurat
ion.java:1226)
        at org.hibernate.ejb.EventListenerConfigurator.configure(EventListe
nerConfigurator.java:173)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.
java:854)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.
java:191)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.
java:253)
Osmanli answered 29/4, 2010 at 5:31 Comment(0)
O
4

I was able to get this working with the following set of dependencies (i.e. 3.5.1-Final for all hibernate jars)

                <dependencies>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-core</artifactId>
                        <version>${hibernate-core.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-entitymanager</artifactId>
                        <version>${hibernate-entitymanager.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-annotations</artifactId>
                        <version>${hibernate-annotations.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>ejb3-persistence</artifactId>
                        <version>3.3.2.Beta1</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-tools</artifactId>
                        <version>${hibernate-tools.version}</version>
                    </dependency>
                </dependencies>
Osmanli answered 30/4, 2010 at 3:53 Comment(3)
Glad it's working but I still don't understand what you did exactly and where you declared these dependencies (inside the plugin?). By the way, you should theoretically not declare hibernate-core and hibernate-annotations, hibernate-entitymanager pulls them transitively. And I don't think that ejb3-persistence is required for JPA 2.0.Flatt
I added these dependencies for the hibernate3-maven-plugin. Without the latest version of ejb3-persistence it wouldn't work.Osmanli
This works for me as well. I was also able to leave out the <dependency> for the hibernate-tools JAR, since I couldn't find a newer version of it and the old hibernate-tools version seems to work fine with the newer hibernate-core and ejb3-persistence artifacts.Muddleheaded
F
2

It's hard to say what is happening exactly but the fact is that the version 2.2. of hibernate3-maven-plugin declares hibernate-core 3.3.1.GA and hibernate-tools 3.2.3.GA as dependencies and is compiled against those versions. Did you try to replace them? If yes, I don't think you can (especially since they seem to introduce non compatible changes).

Having that said, this shouldn't prevent you from declaring hibernate-entitymanager-3.5.1-Final as dependency in your project and let the plugin use other versions (which should be the default behavior).

Flatt answered 29/4, 2010 at 18:56 Comment(1)
Thanks I got this working yesterday with the dependencies which I have mentioned above. It needed all of the above dependencies not just the core jarOsmanli
W
1

I had a similar issue.

After running "mvn dependency:tree", I saw that unitils-dbunit:3.1 depended on an older hibernate.jar...

[INFO] +- org.unitils:unitils-dbunit:jar:3.1:test
[INFO] |  +- org.unitils:unitils-core:jar:3.1:test
[INFO] |  |  +- commons-logging:commons-logging:jar:1.1:test
[INFO] |  |  +- commons-lang:commons-lang:jar:2.5:test (version managed from 2.3)
[INFO] |  |  \- ognl:ognl:jar:2.6.9:test
[INFO] |  +- org.unitils:unitils-database:jar:3.1:test
[INFO] |  |  +- org.unitils:unitils-dbmaintainer:jar:3.1:test
[INFO] |  |  |  \- org.hibernate:hibernate:jar:3.2.5.ga:test

Moving the Hibernate libs before the unitils dependency solved the problem. Order matters.

Good luck, J.

Wiseman answered 9/7, 2010 at 5:23 Comment(0)
A
1

For Hibernate 3.6.0.Final I setup the plugin as follows:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>2.2</version>
    <dependencies>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.6.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft</groupId>
            <artifactId>sqljdbc4</artifactId>
            <version>3.0.1301</version>
        </dependency>
    </dependencies>
</plugin>
Array answered 15/6, 2011 at 15:49 Comment(0)
B
1

This solution is the best for me. Just add one dependency, and it will add the rest of necesary dependencies:

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

Latest version here: http://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager

Boxcar answered 7/5, 2013 at 3:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.