views:

246

answers:

2

I'm trying to build a relative easy project and include Hibernate with maven. I'm trying to use the latest version of Hibernate (3.5.4-Final).

It seems that the JBoss folks have changed their maven repository recently, and I'm having some problems getting my maven build to work. I have found a lot of information on the web and here, but nothing seems to work quite right... Lots of information I have found does not let me get the latest version of Hibernate.

I have the following repository defined in my pom.xml:

<repository>
    <id>jboss-public-repository-group</id>
    <name>JBoss Public Repository Group</name>
    <url>https://repository.jboss.org/nexus/content/repositories/releases&lt;/url&gt;
</repository>

I have the following dependency defined in my pom.xml:

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

This seems to download some of the dependencies, but not enough to build.

I get the following error:

Downloading: http://repo1.maven.org/maven2/org/hibernate/hibernate/3.5.4-Final/hibernate-3.5.4-Final.jar
[INFO] Unable to find resource 'org.hibernate:hibernate:jar:3.5.4-Final' in repository central (http://repo1.maven.org/maven2)

I've read the page JBoss says to read Maven Getting Started - Users, and to be honest it doesn't make any sense to me. It says to put stuff in my settings.xml. I would like to put information in my pom.xml and not require everyone to modify the settings.xml. I'm hardly a maven expert. I just really want to know what to put in my pom.xml file to get this to work.

+2  A: 

Well I found the answer...

This will get the stuff you need. From the page quoted above, add the following to your pom.xml:

<repositories>
    <repository>
        <id>jboss-public-repository-group</id>
        <name>JBoss Public Maven Repository Group</name>
        <url>https://repository.jboss.org/nexus/content/groups/public/&lt;/url&gt;
        <layout>default</layout>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>jboss-public-repository-group</id>
        <name>JBoss Public Maven Repository Group</name>
        <url>https://repository.jboss.org/nexus/content/groups/public/&lt;/url&gt;
        <layout>default</layout>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

Here is the dependency you need:

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.5.4-Final</version>
    </dependency>
Starkey
You don't need to declare a `pluginRepository` to use Hibernate.
Pascal Thivent
+1  A: 

The problem is that this dependency

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate</artifactId>
    <version>3.5.4-Final</version>
    <!-- <type>jar</type> is implied here -->
</dependency>

is just a pom, while you are trying to reference it as a jar. So to reference it, you would have to do it like this:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate</artifactId>
    <version>3.5.4-Final</version>
    <type>pom</type>
</dependency>

This would grab this pom's transitive dependencies, but not the artifact itself. However, the pom only lists modules, not dependencies, as it's the root pom for hibernate. It won't help you, leave it alone.

So what you really want is either

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>3.5.4-Final</version>
</dependency>

(for classic hibernate) or

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

(for the jpa2 provider)

seanizer