1

I'm upgrading some dependency versions I have in a java/maven/spring application, which is using our nexus repo as the central repository mirroring maven central.

I tried upgrading hibernate to it's newest version of 3.5.4-Final as listed:

Hibernate newest release stable version

And when I run maven install, I see in my nexus server that there is now 3.5.4-Final listed, but inside its directory there is only a pom.xml file for the project and none of it's associated JAR's.

When I inspect the POM, I can see it's packaging is listed as POM and not JAR.

Why is this, and how can I make maven take the jar packaged version of the library rather than just the POM?

EDIT - mvn install error message posted:

[ERROR] Failed to execute goal on project app: Could not resolve dependencies for project com.app:app:war:16.2.1-SNAPSHOT: Failure to find org.hibernate:hibernate:jar:3.5.4-Final in http://ssp-nexus1.mynexus-server.com:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of company.nexus.mirror has elapsed or updates are forced -> [Help 1]
Adam Bronfin
  • 1,209
  • 3
  • 27
  • 43

1 Answers1

4

As mentioned in the link you provided

Aggregator of the Hibernate Core modules.

So, the artifact you linked is effectively a pom which aggregates (as a multimodule) other Hibernate artefacts.

Instead, the hibernate-core artifact, as an example, can be found here, as a standard maven dependency (that is, a jar).

By default dependencies have type jar, so if you add the maven coordinates (GAV) for a dependency that is instead of type pom, maven will then look up for it as a jar. So that's why you are getting the error mentioned in your edit.

You should remove its dependency from your pom and only add the hibernate dependency you effectively need. As a rule of thumb, add the dependency you explicitly use in your code (as import statements, for instance) or your configuration files, and let then maven take care of the required transitive dependencies, given that they will be available on your company repository, obviously.

Update
Following your latest comments and feedback, here is a further explanation about why just changing the version of the existing Hibernate dependency you got to this issue:

  • The new 3.5.4-Final and the previous 3.2.7.ga version share the same groupId and artifactId on the Maven repository
  • However, the former has type pom (it's a pom file), while the latter has type jar (the default one)
  • So, the previously existing version was working fine and changing the version of the dependency you switched it from jar to pom, breaking the maven resolution (which was looking for a jar for a version which instead was a pom)
  • This mainly happened because you switched from a ga to a FINAL version. For a further explanation about the difference between these versions, you can check this SO question and this one

As a side note, I find a bit inconsistent that changing a version number also changes the dependency type, it might a point of debate, but if I were the Hibernate team, I would handle this version management differently.

Community
  • 1
  • 1
A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
  • I'll just add that Hibernate is not only one jar, it's packaged into multiples JARs. Using `hibernate-core` dependency/jar will be sufficient in most cases though. – Gaël J Feb 02 '16 at 20:51
  • We use hibernate-core among others such as annotations. I'm trying to update everything hibernate related. What I've been doing is for each hibernate artifact I see listed, is taking the latest version I see for it that's release stable in MVN central. Is this not the correct approach? – Adam Bronfin Feb 02 '16 at 20:57
  • I've added the error I'm getting above. If it's a pom project why is it looking for a jar then? What is the best way to update every hibernate artifact I have listed? – Adam Bronfin Feb 02 '16 at 21:00
  • I actually also have hibernate-core 3.5.4-Final listed as a dependency as well and can see it in my effective-pom. – Adam Bronfin Feb 02 '16 at 21:07
  • Also I can see in our nexus server, there IS a jar for artifactId=hibernate at the following location for an older version: /nexus/content/groups/public/org/hibernate/hibernate/3.2.7.ga/hibernate-3.2.7.ga-sources.jar – Adam Bronfin Feb 02 '16 at 21:19
  • @AdamBronfin I updated my answer explaining the error you got – A_Di-Matteo Feb 02 '16 at 21:53
  • Ok thanks but this dependency was already listed when I inherited this project, so why wasn't it an issue before? Also since it's a POM aggregator, not JAR, why does my nexus server have a jar file for the project in an earlier version? – Adam Bronfin Feb 02 '16 at 22:01
  • 1
    @AdamBronfin the link you posted in your comment is to a sources jar, not a maven dependency you would use in your code. Instead, the 3.2.7.ga version is a [jar](http://mvnrepository.com/artifact/org.hibernate/hibernate/3.2.7.ga), so you changed the version and as such you also change its type (indeed this is a bit inconsistent on the maven repository as well, but explains your issue. I will update the answer accordingly – A_Di-Matteo Feb 03 '16 at 09:30