Tuesday, March 18, 2014

Maven Hell Again and Again

Something is wrong with Maven. Really. Even though no-1 problem of smooth maven operation in my country is no longer an issue (the no 1 problem is low bandwidth internet connectivity, this no longer an issue since my office's bandwidth has been upgraded tremendously), other issues still plague my maven operation today.


See, I have this one production java application, built using Spring Roo (a good technology choice at the moment) and each time the source code changes I am forced to waste time repairing my maven configuration. The problem is a failed dependency resolution that took a long time to investigate.


One of the previous big time-waster when I am using maven is the problematic Maven-Eclipse integration. I avoid Eclipse now, currently I am using IntelliJ's IDEA Community edition.
The error is something like :

At first I was confused that the problem is about stale local repository cache, which I tried to fix using mvn -U switch. Because it does no good, I checked the milestone repository, I found no jta artifact there. Then I thought, why on earth doesn't maven search the central repository. After all, it supposed to have the artifact (HTML fragment from http://mavenhub.com/mvn/central/javax.transaction/jta/1.0.1B#depMaven ) :

After checking fruitlessly at my user settings.xml and global settings.xml seeking a clue where does the central repository got disabled,  I changed maven version from 3.0.5 to 2.2.2.
It turned out that it already did search the maven's central repository in addition to milestone repository and snapshot repository.  Look at the resulting error message :

From there, I double checked the directory list of http://repo1.maven.org/maven2/javax/transaction/jta/1.0.1B/ :

Index of /maven2/javax/transaction/jta/1.0.1B/


../
jta-1.0.1B.pom                                     08-Nov-2005 21:58                 515
jta-1.0.1B.pom.md5                                 22-Nov-2010 06:05                  33
jta-1.0.1B.pom.sha1                                22-Nov-2010 06:05                  41
maven-metadata.xml                                 06-Nov-2006 01:08                 175
maven-metadata.xml.md5                             22-Nov-2010 06:05                  33
maven-metadata.xml.sha1                            22-Nov-2010 06:05                  41


There is no jar file there, but the pom files are there. I got deceived by a few pom files :). So there lies the actual problem.

It is strange that maven 3.0.5 output a different error message than 2.2.1 :
Maven 3.0.5 build failure message




Compare this with 2.2.1 build failure message :


Maven 2.2.1 error message
The second error message tells me that maven already searched central repository. 
This might be counter intuitive, but yes, it might be useful to have multiple Maven versions in your system. 
So what is the solution ? Just add the java.net repository that still keeps the jta-1.0.1B jar file :
 The solution is courtesy of http://stackoverflow.com/questions/9003298/missing-javax-transaction-jta-artifact. So it might be better to start combing stack overflow for solutions anyway. But you need to use the correct search keywords first, such as [unable find jta repository central]. Such keyword doesn't came to mind easily though.

And I also want to point out that it is not necessary to use the mvn -e switch or the mvn -X switch. The complex output doesn't have additional benefit in this case.


1 comment:

Ilguiz Latypov said...

The download.java.net repository seems to have relocated to https://maven.java.net/content/groups/public/, and I see a wiki page suggesting maintainers of artifacts to submit tickets before deploying new releases.

The jta artifact does not show up in the new public repository.