简体   繁体   中英

Maven uses wrong repository to download

I am using a bit older version (1.5) of com.sun.jersey-server/json/client and it has to be this version so please don't suggest to use a newer version.

In my pom.xml I am referencing it with:

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.5</version>
        <type>jar</type>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <!-- version conflicts with explicit direct dependency -->
                <groupId>org.codehaus.jettison</groupId>
                <artifactId>jettison</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Compiling gives this output with error:

    [INFO] Scanning for projects...
    [INFO]------------------------------------------------------------------------
    [INFO] Building MediaAssistantWebService
    [INFO]    task-segment: [clean, install]
    [INFO]------------------------------------------------------------------------
     [...]
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] Copying 1 resource
    Downloading: http://repositories.dai-labor.de/extern/content/repositories/dai-open/com/sun/jersey/jersey-server/1.5/jersey-server-1.5.pom
    [INFO] Unable to find resource 'com.sun.jersey:jersey-server:pom:1.5' in repository dai-open (http://repositories.dai-labor.de/extern/content/repositories/dai-open)
    Downloading: http://download.java.net/maven/2//com/sun/jersey/jersey-server/1.5/jersey-server-1.5.pom 10K downloaded  (jersey-server-1.5.pom)
    Downloading: http://maven.glassfish.org/content/groups/glassfish/com/sun/jersey/jersey-project/1.5/jersey-project-1.5.pom 185b downloaded  (jersey-project-1.5.pom)
    [WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = '6c9fd3d150b8a5f0ca676f49b8ed603793cabebb'; remote = '<html><head><title>301' - RETRYING
    Downloading: http://maven.glassfish.org/content/groups/glassfish/com/sun/jersey/jersey-project/1.5/jersey-project-1.5.pom185b downloaded  (jersey-project-1.5.pom)
    [WARNING] *** CHECKSUM FAILED - Checksum failed on download: local '6c9fd3d150b8a5f0ca676f49b8ed603793cabebb'; remote = '<html><head><title>301' - IGNORING
    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] Error building POM (may not be this project's POM).

    Project ID: null:jersey-server:bundle:null

    Reason: Cannot find parent: com.sun.jersey:jersey-project for project: null:jersey-server:bundle:null for project null:jersey-server:bundle:null

After searching for a solution, I added this repository to my pom so maven looks there first:

<repository>
  <id>maven2-repository.dev.java.net</id>
  <name>Java.net Repository for Maven</name>
  <url>http://download.java.net/maven/2/</url>
  <layout>default</layout>
</repository>

But that didn't do anything. I deleted the .m2/jersey folder and tried mvn clean compile again. It still tries to download it from the glassfish-404 repository.

Does anyone know what I have to change so it will download properly?

Try to add repository of the maven central before others:

<repositories>
    <repository>
        <id>maven-central</id>
        <url>http://repo1.maven.org/maven2</url>
    </repository>
    ...
</repositories>

Better option would be setting up of the nexus server and getting rid of repository sections in pom files: http://www.sonatype.com/people/2009/02/why-putting-repositories-in-your-poms-is-a-bad-idea/

If you look at the pom that is references by jersey, it includes some repo from glassfish.org. http://download.java.net/maven/2//com/sun/jersey/jersey-server/1.5/jersey-server-1.5.pom

<repositories>
    <repository>
        <id>glassfish-repository</id>
        <name>Repository for Glassfish</name>
        <url>http://maven.glassfish.org/content/groups/glassfish</url>
    </repository>
</repositories>

When the transitive dependencies are tried to download, the server sends a redirect response, hence you see checksum error in the log that you provided.

try this in browser: http://maven.glassfish.org/content/groups/glassfish/com/sun/jersey/jersey-project/1.5/jersey-project-1.5.pom

I know this is not solution to your problem (and too cumbersome), but can you try to mvn install the dependencies needed for jerser-server 1.5 locally so that it does not try to download those?

The only solution that worked for me was adding a mirror in settings.xml for the glassfish repository:

<mirror>
    <id>glassfish-mirror</id>
    <name>glassfish mirror</name>
    <url>http://maven.nuxeo.org/nexus/content/repositories/public-releases</url>
    <mirrorOf>glassfish-repository</mirrorOf>
</mirror>

As explained here

I guess it would be fantasy to think that including all the dependencies in the download would be sensible. Of course it's better to have maven download them. It's so much fun to spend hours and hours tracking down which stupid repo or unnecessary bloat jar can't be found! I know I must side with the majority on this one, since no one else is daring to suggest anything to the contrary.

Just adding:

<repository>
    <id>maven-central</id>
    <url>http://repo1.maven.org/maven2</url>
</repository>

To my POM.xml worked fine

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM