Maven, Access denied to: http://repo1.maven.org/maven2

28,346

Solution 1

It seems as though directory browsing on http://repo1.maven.org/maven2 has been switched off. I had to resort to getting the archetype catalog myself. I did this:

mvn archetype:generate -DarchetypeCatalog=http://search.maven.org/remotecontent?filepath=archetype-catalog.xml

Alternatively I guess you could just download the archetype-catalog.xml file from that link and place it in your .m2 directory as mentioned in this comment:

http://jira.codehaus.org/browse/ARCHETYPE-202?focusedCommentId=182771&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-182771

Solution 2

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.

Solution 3

Execute this Command. It will not only create your maven project but also resolve the issue of downloading archetype jar. It is mainly due to unavailability to the archetype URL.

Fill Project Group Id with your project names.

mvn archetype:generate -DgroupId={Project Group Id} -DartifactId={Project Id} -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false -DarchetypeCatalog=http://search.maven.org/remotecontent?filepath=archetype-catalog.xml

Solution 4

it seem to work with maven 2 (reproduced the problem on 3 machines linux and windows with maven 3.05 and maven 3.1)

the problem occurs only for the repo1... urls. If you delete your local repository, all plugin downloads will work fine until the download of archetype catalog - "access denied"

Share:
28,346
Vovan
Author by

Vovan

Updated on August 23, 2022

Comments

  • Vovan
    Vovan over 1 year

    I have just downloaded last version of Maven.

    And when i am trying to run

    mvn archetype:generate

    i get error message

    [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(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 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] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)

    I have not Proxy and internet works fine. Firewall is turned off. How to solve this problem ?

    Thx for your help.

    If we look to the class org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon method fillInputData( InputData inputData ) we can see this:

    public void fillInputData( InputData inputData )
           throws TransferFailedException, ResourceDoesNotExistException,AuthorizationException
        {
         ....
     HttpResponse response;
         ....
     statusCode = response.getStatusLine().getStatusCode();
         ....
     switch ( statusCode )
            {
                case HttpStatus.SC_OK:
                    break;
    
                case HttpStatus.SC_NOT_MODIFIED:
                    // return, leaving last modified set to original value so getIfNewer should return unmodified
                    return;
    
                case SC_NULL:
                {
                    TransferFailedException e =
                        new TransferFailedException( "Failed to transfer file: " + url + reasonPhrase );
                    fireTransferError( resource, e, TransferEvent.REQUEST_GET );
                    throw e;
                }
    
                case HttpStatus.SC_FORBIDDEN:    // <---------THIS
                    fireSessionConnectionRefused();
                    throw new AuthorizationException( "Access denied to: " + url + reasonPhrase);
           ....
             }
    ...
    }
    

    So problem caused because we have HTTP 403 Forbidden error in response. But i dont know what to do...


    So now we know that we are getting FORBIDDEN error because we have not User-Agent in HTTP request. Thanx to Patouche

  • Vovan
    Vovan over 10 years
    Yes. For me is quite so.
  • Vovan
    Vovan over 10 years
    Is there any hope that they will fix this ?
  • Chopstick
    Chopstick over 10 years
    I hope they will fix this; I currently have no idea and my message to the #maven irc channel has so far gone unanswered. I guess the best bet is to subscribe to the mailing list and ask them there.
  • Vovan
    Vovan over 10 years
    they have to add just one line to org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon class, to set up user-agent :(
  • dermoritz
    dermoritz over 10 years
    but this explans not the fact that it is still working with maven 2
  • Mark Bennett
    Mark Bennett over 10 years
    Also hit this over on stackoverflow.com/questions/18473398 and somebody linked to here in the comments. Yes, I hope they fix it - it's madness! It's particularly annoying because it'll likely be hit by new maven users trying to create their first project, and they'll assume it's some issue with their system.
  • Patouche
    Patouche over 10 years
    It's a nice solution. I prefer to make a wget of the archetype catalog in my .m2 directory until the latest maven release will be out.
  • Vovan
    Vovan over 10 years
    but when will came out 3.1.1 version ?
  • Mark Bennett
    Mark Bennett over 10 years
    Sadly maven 3.1x broke some other stuff I was working with, that's why I had to retreat to 3.0.5. From this answer stackoverflow.com/a/18550459/295802 I wonder if 3.0.4 might also work.
  • The Student
    The Student over 6 years
    for me it was the antivirus/firewall