views:

977

answers:

4

I added the JBoss Maven repo to my pom.xml file like this...

 <repositories>
        <repository>
            <id>jboss</id>
            <url>http://repository.jboss.org/maven2/&lt;/url&gt;        
        </repository>
    </repositories>

And I added Hibernate itself like this...

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

But when I try to build my application I see this error....

Downloading: http://repository.jboss.org/maven2//org/hibernate/hibernate/3.5.1-Final/hibernate-3.5.1-Final.jar
[INFO] Unable to find resource 'org.hibernate:hibernate:jar:3.5.1-Final' in repository jboss (http://repository.jboss.org/maven2/)
Downloading: http://repo1.maven.org/maven2/org/hibernate/hibernate/3.5.1-Final/hibernate-3.5.1-Final.jar
[INFO] Unable to find resource 'org.hibernate:hibernate:jar:3.5.1-Final' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) org.hibernate:hibernate:jar:3.5.1-Final

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.hibernate -DartifactId=hibernate -Dversion=3.5.1-Final -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.hibernate -DartifactId=hibernate -Dversion=3.5.1-Final -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) stakeholdersupdate:stakeholdersupdate:war:1.0
    2) org.hibernate:hibernate:jar:3.5.1-Final

----------
1 required artifact is missing.
+2  A: 

the hibernate artifact is of type pom (meaning it is only a wrapper for other projects). do this:

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

(if you leave out the type, maven will try to resolve the artifact as a jar, which doesn't exist in this case)

seanizer
+1 for the reason of the error
Pascal Thivent
+3  A: 

As seanizer mentioned, the org.hibernate:hibernate:pom:3.5.1-Final artifact is an aggregating modules of type pom (it aggregates the Hibernate Core modules). So you could indeed depend on it by specifying a <type>pom</type>. But I would personally declare a dependency on the wanted module, for example for Hibernate Entity Manager:

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

Or for Hibernate Core:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>3.5.1-Final</version>
</dependency>
Pascal Thivent
that's right of course. I just answered the question, while providing the answer to an implied better question would have been the way to go :-)
seanizer
Ah drat, you already went along 66666! :o)
BalusC
@BalusC: I took a screenshot! >:)
Pascal Thivent
A: 

Kindly note that all future JBoss artifacts will not be available in the old repository. JBoss is moving to a new maven repository infrastructure.

James Selvakumar
A: 

This is how I managed to add Hibernate and JPA 2 to my project

. . .

<repositories>
    <repository>
        <id>JBoss</id>
        <name>The "public-jboss" repository group provides a combined view all JBoss community project artifacts</name>
        <layout>default</layout>
        <url>http://repository.jboss.org/nexus/content/groups/public-jboss&lt;/url&gt;
    </repository>
</repositories>

<dependencies>

    . . .

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

    . . .

</dependencies>

. . .
aurelije