Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: "Error reading archetype catalog", NOT behind a Proxy

Command:

mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DgroupId=org.apache.solr -DartifactId=es-my-proj

Error (full stack at bottom):

...
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[WARNING] Error reading archetype catalog http://repo1.maven.org/maven2
org.apache.maven.wagon.authorization.AuthorizationException: Access denied to: http://repo1.maven.org/maven2 , ReasonPhrase:Denied Access.
    at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:928)
    ...

Every google search I've done comes up with one of these answers, but none of which are applicable:

  • Behind a proxy - but I'm not behind a proxy!
  • Some bug back in 2010 with Maven 2.x, but I'm on Maven 3.0.5
  • Mangled settings file, but I don't even have a ~/.m2/settings.xml file

Other things I've checked:

  • Each time I make sure there's no directory and no pom file, etc.
  • Also tried adding -DarchetypeRepository=http://repo2.maven.org/maven2 but same result
  • The "Access denied" was odd - I am able to visit both repo1 and repo2 from a browser (though the server says browsing has been disabled of course)
  • Maven 3.0.5, Oracle Java 7 (1.7.0_25), on Mountain Lion (OS X 10.8.4)

It does create a project using some 1x template, I don't know how good or bad that is.

Full stack trace:

mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DgroupId=org.apache.solr -DartifactId=my-proj-name
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>>
[INFO] 
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<<
[INFO] 
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[WARNING] Error reading archetype catalog http://repo1.maven.org/maven2
org.apache.maven.wagon.authorization.AuthorizationException: Access denied to: http://repo1.maven.org/maven2 , ReasonPhrase:Denied Access.
    at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:928)
    at org.apache.maven.wagon.StreamWagon.getInputStream(StreamWagon.java:116)
    at org.apache.maven.wagon.StreamWagon.getIfNewer(StreamWagon.java:88)
    at org.apache.maven.wagon.StreamWagon.get(StreamWagon.java:61)
    at org.apache.maven.archetype.source.RemoteCatalogArchetypeDataSource.downloadCatalog(RemoteCatalogArchetypeDataSource.java:119)
    at org.apache.maven.archetype.source.RemoteCatalogArchetypeDataSource.getArchetypeCatalog(RemoteCatalogArchetypeDataSource.java:87)
    at org.apache.maven.archetype.DefaultArchetypeManager.getRemoteCatalog(DefaultArchetypeManager.java:216)
    at org.apache.maven.archetype.DefaultArchetypeManager.getRemoteCatalog(DefaultArchetypeManager.java:205)
    at org.apache.maven.archetype.ui.generation.DefaultArchetypeSelector.getArchetypesByCatalog(DefaultArchetypeSelector.java:200)
    at org.apache.maven.archetype.ui.generation.DefaultArchetypeSelector.selectArchetype(DefaultArchetypeSelector.java:71)
    at org.apache.maven.archetype.mojos.CreateProjectFromArchetypeMojo.execute(CreateProjectFromArchetypeMojo.java:197)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[WARNING] No archetype found in remote catalog. Defaulting to internal catalog
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: maven-archetype-quickstart:1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.apache.solr
[INFO] Parameter: packageName, Value: org.apache.solr
[INFO] Parameter: package, Value: org.apache.solr
[INFO] Parameter: artifactId, Value: my-proj-name
[INFO] Parameter: basedir, Value: /Users/mbennett/dev
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: /Users/mbennett/dev/my-proj-name
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.563s
[INFO] Finished at: Tue Aug 27 11:47:28 PDT 2013
[INFO] Final Memory: 15M/206M
[INFO] ------------------------------------------------------------------------
like image 427
Mark Bennett Avatar asked Aug 27 '13 18:08

Mark Bennett


3 Answers

The Apache Maven team faced the same issue with one of their integration-tests, see the related message-thread. So it seems that during the last week of August the policy has changed and it is not possible to get these xml files without a User-Agent in the request. There's no option in the Maven Settings to set this value, neither have I found another way to set it.

I can confirm that Maven-3.0.4 does work, but this version has a security issue. According to other posts other older versions of Maven seem to work as well.

Unless Maven Central changes its policy, this is something which needs to be fixed in the next Maven release.

like image 133
Robert Scholte Avatar answered Oct 13 '22 08:10

Robert Scholte


It seems like Apache central repository has fixed the issue. So without making any change, the problem is fixed now. Please try once again and let us know in case of any issue.

like image 40
Tamal Kanti Nath Avatar answered Oct 13 '22 09:10

Tamal Kanti Nath


I got the same error yesterday. I didn't finish to find the solution yet but I have a idea why we have this errror.

After hours of digging in the maven-archetype-plugin, I didn't notice something strange...

So i decide to run the same command again with a tcpflow running to capture the sended request. Here is the result :

192.168.000.010.59775-185.031.016.185.00080: GET /maven2/archetype-catalog.xml HTTP/1.1
Cache-control: no-cache
Cache-store: no-store
Pragma: no-cache
Expires: 0
Accept-Encoding: gzip
Host: repo1.maven.org
Connection: Keep-Alive


185.031.016.185.00080-192.168.000.010.59775: HTTP/1.1 403 Denied Access
Server: Varnish
Retry-After: 0
Content-Type: text/html; charset=utf-8
Content-Length: 401
Accept-Ranges: bytes
Date: Fri, 30 Aug 2013 01:53:29 GMT
Via: 1.1 varnish
Age: 0
Connection: close
X-Served-By: cache-am70-AMS
X-Cache: MISS
X-Cache-Hits: 0

So, a Guru Meditation error. I like Varnish !! After that, I notice using netcat that, if you add a User-Agent (anything) in the request, everything works fine !!

[07:49][patouche@patouche-desktop:~ :) ] $ nc repo1.maven.org 80
GET /maven2/archetype-catalog.xml HTTP/1.1
Cache-control: no-cache
Cache-store: no-store
Pragma: no-cache
Expires: 0
Accept-Encoding: gzip
Host: repo1.maven.org
Connection: Keep-Alive
User-Agent: I have a dream...

HTTP/1.1 200 OK
Server: nginx/1.2.1
Content-Type: text/xml
Last-Modified: Tue, 27 Aug 2013 11:06:25 GMT
Via: 1.1 varnish
Content-Length: 1663366
Accept-Ranges: bytes
Date: Fri, 30 Aug 2013 05:50:09 GMT
Via: 1.1 varnish
Age: 81998
Connection: keep-alive
X-Served-By: cache-c32-CHI, cache-l22-LON
X-Cache: HIT, HIT
X-Cache-Hits: 5, 1

So, if you add a User-Agent in the request, everything will work. I thinks with the settings.xml but I don't know how for now.

like image 35
Patouche Avatar answered Oct 13 '22 10:10

Patouche