2012年7月13日金曜日

asm-3.1.jar; error in opening zip file

I encountered a Maven error caused by asm-3.1.jar. The error message was saying:

error: error reading /root/.m2/repository/asm/asm/3.1/asm-3.1.jar; error in opening zip file

I found soon that asm-3.1.jar in .m2 was not a (corrupt) jar file but an HTML file whose content was as follows:

<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/0.6.39</center>
</body>
</html>

It seems 'mvn' cannot handle '301 Moved Permanently' properly.

So, I downloaded asm-3.1.jar from the central repository,

central / asm / asm / 3.1
http://search.maven.org/#browse|-447836703
http://search.maven.org/remotecontent?filepath=asm/asm/3.1/asm-3.1.jar

and copied it to the local repository.

$ cp asm-3.1.jar ~/.m2/repository/asm/asm/3.1/asm-3.1.jar
$ rm ~/.m2/repository/asm/asm/3.1/asm-3.1.pom

This worked in my case.


Edit: 2012/11/14

Probably, a better way than 'cp' is to use 'mvn install:install-file'. After downloading asm-3.1.pom, then type:

$ mvn install:install-file -Dfile=asm-3.1.jar -DgroupId=asm -DartifactId=asm -Dversion=3.1 -Dpackaging=jar -DpomFile=asm-3.1.pom

See also:

Installing an artifact to a specific local repository path
http://maven.apache.org/plugins/maven-install-plugin/examples/specific-local-repo.html