views:

3694

answers:

3

I am having trouble getting the latest release of Hibernate via Maven dependency. It appears that the latest I can fetch from a Maven central repository is 3.2.6.GA, and I am interested in using 3.3.2.GA, which is the latest release shown on the hibernate.org site. When I modify my hibernate dependency to this latest version in my project's pom.xml I get the following error when I run a Maven build:

Missing:
----------
1) org.hibernate:hibernate:jar:3.3.2.GA

  Try downloading the file manually from the project website.

  Then, install it using the command:
      mvn install:install-file -DgroupId=org.hibernate -DartifactId=hibernate -D
version=3.3.2.GA -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 -Dve
rsion=3.3.2.GA -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[
id]

Once I do that I continue to get errors indicating that I need to add a javassist dependency, then I need to update my hibernate-validator dependency, which also needs to be installed locally, and at that point I stopped and looked around to see if there is a better way, maybe pointing Maven to a JBoss/Hibernate repository, etc. This really seems to be a headache compared to other significant open cource packages that I use such as Spring or JUnit -- when there's a new version released all I do is update the version number in the dependency element and it just works.

I have tried adding the below repository declaration into my pom.xml but with no joy:

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

I searched Google and didn't find much which helps. Can someone suggest the most straight-forward way of going about using the latest releases of hibernate or hibernate-core (3.3.2.GA), hibernate-validator (3.1.0), and hibernate-annotations (3.4.0)?

Thanks in advance for your help!

--James

A: 

the jars are missing in the repository, maybe that is the reason the latest hibernate version is not in the main repoistory

Salandur
I can see the jars in the repository: <p>http://repository.jboss.org/maven2/org/hibernate/hibernate-core/3.3.2.GA/hibernate-core-3.3.2.GA.jar<p>http://repository.jboss.org/maven2/org/hibernate/hibernate-validator/3.1.0.GA/hibernate-validator-3.1.0.GA-sources.jar<p>http://repository.jboss.org/maven2/org/hibernate/hibernate-annotations/3.4.0.GA/hibernate-annotations-3.4.0.GA.jar
James Adams
that explains a little. apparently hibernate is renamed to hibernate-core and the jars are put there. but the don't follow the naming convention, so there are not usable with maven...
Salandur
+1  A: 

It's frustrating, but the newer versions just aren't there, and haven't been for a long time. The irony is that the Hibernate artifacts have some fairly intricate inter-dependencies and well-documented minimum versions of those dependencies, which would be ideally represented as a Maven POM. Instead, we have to download the binaries ourselves and try and express them locally.

skaffman
+7  A: 

You're having problems because org.hibernate:hibernate:3.3.2.GA is an aggregator POM used to build the rest of the modules, it isn't actually a jar. It looks like a refactoring happened after 3.2.7 and that's thrown people off. For reference this blog entry hints at problems they've had promoting Hibernate to central and may explain the change.

If you look in the JBoss repository, you'll see that the hibernate modules for 3.3.2.GA are hosted, they're just hosted as individual artifacts, hibernate-core, hibernate-ehcache etc. So your repository declaration is correct, you just need to fine tune the dependency declarations to take the change into account.

The JBoss repository hosts hibernate-annotations-3.4.0.GA, hibernate-validator-3.1.0.GA, and hibernate-core-3.3.2.GA amongst others. Try adding the specific artifacts to your POM and use the JBoss repository as you've already declared.

There is also a hibernate-dependencies pom that provides transitive dependencies to the majority of hibernate artifacts (including core). So the simplest thing to do would be to replace your existing hibernate dependency declaration with hibernate-dependencies

Your dependencies would end up like this...

<dependencies>
  <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-dependencies <!--or hibernate-core--></artifactId>
    <version>3.3.2.GA</version>
    <type>pom</type>
    <!--hibernate-dependencies is a pom, not needed for hibernate-core-->
  </dependency>
  <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-annotations</artifactId>
    <version>3.4.0.GA</version>
  </dependency>
  <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>3.1.0.GA</version>
  </dependency>
  ...
  <!--any other hibernate deps not inherited transitively-->

To make your life simpler you could define all these hibernate dependencies in a project say called (hibernate-all), then reference that single project for all your projects that use hibernate (of course it would be nice if the hibernte team provided that project anyway).

Rich Seller
Wonder why I'm seeing errors like the below when I run my build after adding the repository and dependencies above? [INFO] Unable to find resource 'org.hibernate:hibernate-dependencies:jar:3.3.2.GA' in repository jboss (http://repository.jboss.org/maven2)
James Adams
hibernate-dependencies is a pom project, so you need to set <type>pom</type> on the dependency declaration, alternatively use hibernate-core
Rich Seller
@monocongo, did this work for you with the type set to pom?
Rich Seller
@Rich: I have the same issue, and no, setting `<type>pom</type>` doesn't help
Nader Shirazie