Maven Wagon

Permament move (error 301) not handled properly by Lightweight HTTP Wagon

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0-beta-6
  • Fix Version/s: 2.0
  • Component/s: wagon-http-lightweight
  • Labels:
    None
  • Patch Submitted:
    Yes
  • Number of attachments :
    1

Description

Artifact cannot be downloaded by http-lightweight-wagon used (as default) in all Maven versions except 2.2.0, which uses http-wagon by default.
Instead of pom and jar files html files appear in the local repo with content like:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://download.java.net/maven/2/org/codehaus/castor/castor-xml-schema/1.2/castor-xml-schema-1.2.pom">here</a>.</p>
<hr>
<address>Apache Server at maven2-repository.dev.java.net Port 443</address>
</body></html>

Only Maven 2.2.0 handles 301 properly.

By the way, I haven't expected such Apache configuration (permament move) in central Maven repo.
As you can see this is not handled properly by almost all versions of Maven.

Issue Links

Activity

Hide
Benjamin Bentmann added a comment -

By the way, I haven't expected such Apache configuration (permament move) in central Maven repo.

As a side note, the central Maven repository is repo1.maven.org, not "Apache Server at maven2-repository.dev.java.net Port 443".

Show
Benjamin Bentmann added a comment -
By the way, I haven't expected such Apache configuration (permament move) in central Maven repo.
As a side note, the central Maven repository is repo1.maven.org, not "Apache Server at maven2-repository.dev.java.net Port 443".
Hide
Paul Loy added a comment -

I would suggest that this is a little more important than minor. I'm having to add about 10 repos to my pom in order to work around this issue with redirects and the default maven repo.

Show
Paul Loy added a comment - I would suggest that this is a little more important than minor. I'm having to add about 10 repos to my pom in order to work around this issue with redirects and the default maven repo.
Hide
Steve Kuo added a comment - - edited

This should be major priority. Basically if any repository returns HTTP 301 Moved, then Maven blindly copies the moved HTML as a JAR (an obvious bug). The result is that the build is broken. I've had to edit my settings.xml and create a local repository with manually downloaded JARs - a major pain. See also http://jira.codehaus.org/browse/MEV-649

Show
Steve Kuo added a comment - - edited This should be major priority. Basically if any repository returns HTTP 301 Moved, then Maven blindly copies the moved HTML as a JAR (an obvious bug). The result is that the build is broken. I've had to edit my settings.xml and create a local repository with manually downloaded JARs - a major pain. See also http://jira.codehaus.org/browse/MEV-649
Hide
Benjamin Jaton added a comment -

Definitively a major issue since log4j 1.2.15 is impacted ( MEV-649 )
This bugs seems to be around since a long time though : MAVEN-1831 ( 31/Jan/07 ), I don't know why such a blocking issue hasn't been fixed already.

Show
Benjamin Jaton added a comment - Definitively a major issue since log4j 1.2.15 is impacted ( MEV-649 ) This bugs seems to be around since a long time though : MAVEN-1831 ( 31/Jan/07 ), I don't know why such a blocking issue hasn't been fixed already.
Hide
Kyle W. Cartmell added a comment -

+1 to fix ASAP - this is a huge problem as it breaks log4j 1.2.15 as Benjamin has previously stated.

Show
Kyle W. Cartmell added a comment - +1 to fix ASAP - this is a huge problem as it breaks log4j 1.2.15 as Benjamin has previously stated.
Hide
Data Nucleus added a comment - - edited

+1. Recent changes in SUN's M2 repo has broken local repos for me for artifacts for JMX, JMXTOOLS, JMS, MAIL, as per one of the linked JIRAs (about log4j, saying it is log4j's POM fault, but then Maven shouldn't break the repo in the first place)

Show
Data Nucleus added a comment - - edited +1. Recent changes in SUN's M2 repo has broken local repos for me for artifacts for JMX, JMXTOOLS, JMS, MAIL, as per one of the linked JIRAs (about log4j, saying it is log4j's POM fault, but then Maven shouldn't break the repo in the first place)
Hide
Stephen Compall added a comment -

The underlying cause seems to be wagon-http-lightweight's reliance on HttpURLConnection's redirect behavior. One should first note that all the problematic redirects in question are cross-protocol, i.e. https->http or vice versa.

Then, consider sun.net.www.protocol.http.HttpURLConnection.followRedirect, which always returns false (don't follow) when the protocol of the old URL doesn't match that of the new one. See line 1830 in openjdk-6-src-b18-16_feb_2010 for the specifics.

Many thanks to John Raymond Wold for figuring out why the HttpURLConnection wasn't redirecting.

Show
Stephen Compall added a comment - The underlying cause seems to be wagon-http-lightweight's reliance on HttpURLConnection's redirect behavior. One should first note that all the problematic redirects in question are cross-protocol, i.e. https->http or vice versa. Then, consider sun.net.www.protocol.http.HttpURLConnection.followRedirect, which always returns false (don't follow) when the protocol of the old URL doesn't match that of the new one. See line 1830 in openjdk-6-src-b18-16_feb_2010 for the specifics. Many thanks to John Raymond Wold for figuring out why the HttpURLConnection wasn't redirecting.
Hide
Stephen Compall added a comment -

Patch to wagon-1.0-beta-2 to drive redirects not automatically handled; see my previous comment.

Show
Stephen Compall added a comment - Patch to wagon-1.0-beta-2 to drive redirects not automatically handled; see my previous comment.
Hide
ERt added a comment -

Workaround:
1. In your local repository find pom which declare inappropriate repository
2. Remember "id" of it repository
3. Add this repository to your pom with same id and url
4. Add <enabled>false</enabled> in <releases> and <snapshots>
5. Add right repository to your pom

Show
ERt added a comment - Workaround: 1. In your local repository find pom which declare inappropriate repository 2. Remember "id" of it repository 3. Add this repository to your pom with same id and url 4. Add <enabled>false</enabled> in <releases> and <snapshots> 5. Add right repository to your pom
Hide
Graham Leggett added a comment -

This is a major regression that completely sinks all maven versions newer than v2.2.0, a patch has been available since March, but the patch has been ignored, this bug is unassigned and is marked as "minor".

Is this on the radar for anyone to fix, or has it fallen through the cracks?

Show
Graham Leggett added a comment - This is a major regression that completely sinks all maven versions newer than v2.2.0, a patch has been available since March, but the patch has been ignored, this bug is unassigned and is marked as "minor". Is this on the radar for anyone to fix, or has it fallen through the cracks?
Hide
Paul Davis added a comment -

ERt, I tried the workaround and it didn't work for the codehaus cargo module.

I'm with Graham on this one, what's the big deal with getting the patch applied?

Show
Paul Davis added a comment - ERt, I tried the workaround and it didn't work for the codehaus cargo module. I'm with Graham on this one, what's the big deal with getting the patch applied?
Hide
Anders Hammar added a comment -

Paul, for a workaround for Cargo, see CARGO-840. I've tried the configuration in that ticket and it does work.

Show
Anders Hammar added a comment - Paul, for a workaround for Cargo, see CARGO-840. I've tried the configuration in that ticket and it does work.
Hide
Jesse Glick added a comment -

Confirming that the JRE's implementation does not reliably handle redirects. See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4620571 in the Evaluation section.

Show
Jesse Glick added a comment - Confirming that the JRE's implementation does not reliably handle redirects. See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4620571 in the Evaluation section.
Hide
Dennis Lundberg added a comment -

I tried to apply Stephen's patch to wagon trunk, but it fails to apply. Is there any chance that you could update the patch so that it applies cleanly to trunk?

Show
Dennis Lundberg added a comment - I tried to apply Stephen's patch to wagon trunk, but it fails to apply. Is there any chance that you could update the patch so that it applies cleanly to trunk?
Hide
Wonne Keysers added a comment -

I can confirm that only version 2.2.0 handles permanent redirects properly.
I would realy recommend including a fix in Maven 3 !

Show
Wonne Keysers added a comment - I can confirm that only version 2.2.0 handles permanent redirects properly. I would realy recommend including a fix in Maven 3 !
Hide
Mark Struberg added a comment -

redirects seem to work as expected in wagon-http-lightweight-2.0-SNAPSHOT. There are 4 TCK unit tests for the behaviour now + I tested the functionality against
http://repository.apache.org/content/repositories/snapshots/commons-daemon/commons-daemon/1.0.6-dev-SNAPSHOT

I've deployed the latest wagon-2.0-SNAPSHOT artifacts to the apache.snapshots repository.
Please test the behaviour yourself by adding something like the following snipplet to your pom:

<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>2.0-SNAPSHOT</version>
</extension>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId>
<version>2.0-SNAPSHOT</version>
</extension>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http</artifactId>
<version>2.0-SNAPSHOT</version>
</extension>
</extensions>
</build>

Show
Mark Struberg added a comment - redirects seem to work as expected in wagon-http-lightweight-2.0-SNAPSHOT. There are 4 TCK unit tests for the behaviour now + I tested the functionality against http://repository.apache.org/content/repositories/snapshots/commons-daemon/commons-daemon/1.0.6-dev-SNAPSHOT I've deployed the latest wagon-2.0-SNAPSHOT artifacts to the apache.snapshots repository. Please test the behaviour yourself by adding something like the following snipplet to your pom: <build> <extensions> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-ftp</artifactId> <version>2.0-SNAPSHOT</version> </extension> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-http-lightweight</artifactId> <version>2.0-SNAPSHOT</version> </extension> <extension> <groupId>org.apache.maven.wagon</groupId> <artifactId>wagon-http</artifactId> <version>2.0-SNAPSHOT</version> </extension> </extensions> </build>
Hide
Mark Struberg added a comment -

fixed in r1135334

Show
Mark Struberg added a comment - fixed in r1135334

People

Vote (27)
Watch (25)

Dates

  • Created:
    Updated:
    Resolved: