سؤال

I'm having trouble performing a clean install on my Maven project. This was an old web project that I converted to Maven using Eclipse Kepler's 'Convert to Maven Project' functionality. I am using JDK 1.6, with both project and workspace compliance set to 1.6 as well. After converting the project to Maven, I began configuring the pom. This went fine for the most part.

Unfortunately, once I deployed to a local Tomcat 3.0.36 server, at runtime, I found more errors indicating missing Jars; this was expected, and the two that were missing were added to the pom. Once these two jars were added to the pom, I was unable to build, as Maven says that it cannot transfer the dependencies to my local repository, from Maven's central repository, due to being unauthorized.

I do not have proxies set up in my config, and I'm almost positive I don't need to set them up, particularly since I can retrieve other dependencies and their metadata, just not these two Jars. I do have one mirror configured in my Maven settings, just as a backup in case central is over loaded.

Does anyone know what is going on here? Is it something to do with the "shibboleth" URL in the error log? Do I need to exclude all rampart dependencies and manually add them to the POM?

The error log:

[DEBUG] Using mirror Central (http://repo1.maven.org/maven2) for central (http://repo.maven.apache.org/maven2).
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=3, ConflictMarker.markTime=1, ConflictMarker.nodeCount=445, ConflictIdSorter.graphTime=2, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=87, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=34, ConflictResolver.conflictItemCount=180, DefaultDependencyCollector.collectTime=9571, DefaultDependencyCollector.transformTime=42}
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.129s
[INFO] Finished at: Thu Oct 31 15:48:18 EDT 2013
[INFO] Final Memory: 7M/120M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project <project>: Could not resolve dependencies for project com.<company>:<project>:war:0.0.1: Failed to collect dependencies at org.opensaml:opensaml:jar:2.2.1 -> org.opensaml:openws:jar:1.2.0 -> org.opensaml:xmltooling:jar:1.1.0 -> org.bouncycastle:bcprov-ext-jdk15:jar:1.40: Failed to read artifact descriptor for org.bouncycastle:bcprov-ext-jdk15:jar:1.40: Could not transfer artifact org.bouncycastle:bcprov-ext-jdk15:pom:1.40 from/to Central (http://repo1.maven.org/maven2): Not authorized , ReasonPhrase:Unauthorized. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project <project>: Could not resolve dependencies for project com.<company>:<project>:war:0.0.1: Failed to collect dependencies at org.opensaml:opensaml:jar:2.2.1 -> org.opensaml:openws:jar:1.2.0 -> org.opensaml:xmltooling:jar:1.1.0 -> org.bouncycastle:bcprov-ext-jdk15:jar:1.40
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:220)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:127)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:257)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:200)
    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:317)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project com.<company>:<project>:war:0.0.1: Failed to collect dependencies at org.opensaml:opensaml:jar:2.2.1 -> org.opensaml:openws:jar:1.2.0 -> org.opensaml:xmltooling:jar:1.1.0 -> org.bouncycastle:bcprov-ext-jdk15:jar:1.40
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:167)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:195)
    ... 23 more
Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to collect dependencies at org.opensaml:opensaml:jar:2.2.1 -> org.opensaml:openws:jar:1.2.0 -> org.opensaml:xmltooling:jar:1.1.0 -> org.bouncycastle:bcprov-ext-jdk15:jar:1.40
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:292)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:317)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:159)
    ... 24 more
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.bouncycastle:bcprov-ext-jdk15:jar:1.40
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:335)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:217)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:461)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:573)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:573)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:573)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:261)
    ... 26 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact org.bouncycastle:bcprov-ext-jdk15:pom:1.40 from/to Central (http://repo1.maven.org/maven2): Not authorized , ReasonPhrase:Unauthorized.
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:459)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:262)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:239)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:320)
    ... 32 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact org.bouncycastle:bcprov-ext-jdk15:pom:1.40 from/to Central (http://repo1.maven.org/maven2): Not authorized , ReasonPhrase:Unauthorized.
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1016)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1004)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:725)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.maven.wagon.authorization.AuthorizationException: Not authorized , ReasonPhrase:Unauthorized.
    at org.apache.maven.wagon.shared.http4.AbstractHttpClientWagon.fillInputData(AbstractHttpClientWagon.java:932)
    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.eclipse.aether.connector.wagon.WagonRepositoryConnector$GetTask.run(WagonRepositoryConnector.java:660)
    ... 4 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Here is my pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.company</groupId>
    <artifactId>project</artifactId>
    <version>0.0.1</version>
    <packaging>war</packaging>
    <name>Web Services</name>
    <description>This project handles communication.</description>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

    <repositories>
        <repository>
            <id>opensaml</id>
            <name>OpenSAML Repository</name>
            <url>https://build.shibboleth.net/nexus/content/repositories/releases</url>
    </repository>
</repositories>

    <build>
        <sourceDirectory>src</sourceDirectory>

        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
            </excludes>
        </resource>
    </resources>

        <plugins>
            <!-- This plugin installs the Evip jar from the project's lib to the local 
            repository for normal Maven consumption -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>install-evip-jar</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
                <configuration>
                    <executable>mvn</executable>
                    <arguments>
                        <argument>install:install-file</argument>
                        <argument>-Dfile=${basedir}\WebContent\WEB-INF\lib\EVIPSoapServer.jar</argument>
                        <argument>-DgroupId=com.convergys</argument>
                        <argument>-DartifactId=EVIPSoapServer</argument>
                        <argument>-Dversion=1.0.0</argument>
                        <argument>-Dpackaging=jar</argument>
                </arguments>
            </configuration>
        </plugin>

            <!-- This will compile source files into class files -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
            </configuration>
        </plugin>

            <!-- This includes java source files in the same location as class files -->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                    <webResources>
                        <resource>
                            <directory>${project.build.sourceDirectory}</directory>
                            <targetPath>WEB-INF/classes</targetPath>
                    </resource>
                </webResources>
            </configuration>
        </plugin>
    </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                        org.codehaus.mojo
                                    </groupId>
                                        <artifactId>
                                        exec-maven-plugin
                                    </artifactId>
                                        <versionRange>
                                        [1.2.1,)
                                    </versionRange>
                                        <goals>
                                            <goal>exec</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

    <dependencies>
        <!-- COMPILE DEPENDENCIES -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
            <scope>compile</scope>
    </dependency>
        <dependency>
            <groupId>com.convergys</groupId>
            <artifactId>EVIPSoapServer</artifactId>
            <version>1.0.0</version>
            <scope>compile</scope>
    </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.1.3</version>
            <scope>compile</scope>
    </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-jaxws</artifactId>
            <version>1.5.4</version>
    </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>1.5.4</version>
            <scope>compile</scope>
    </dependency>
        <dependency>
            <groupId>axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.4</version>
            <scope>compile</scope>
    </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-local</artifactId>
            <version>1.5.4</version>
            <scope>compile</scope>
    </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-transport-http</artifactId>
            <version>1.5.4</version>
    </dependency>
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-kernel</artifactId>
            <version>1.5.4</version>
            <scope>compile</scope>
            <exclusions>
                <!-- CANNOT HAVE SERVLET-API IN WEB-INF/LIB FOLDER -->
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
        <dependency>
            <groupId>org.apache.rampart</groupId>
            <artifactId>rampart-trust</artifactId>
            <version>1.5.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.xalan</groupId>
                    <artifactId>xalan</artifactId>
            </exclusion>
                <exclusion>
                    <groupId>org.opensaml</groupId>
                    <artifactId>opensaml</artifactId>
            </exclusion>
                <exclusion>
                    <groupId>org.opensaml</groupId>
                    <artifactId>openws</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
        <dependency>
            <groupId>org.apache.rampart</groupId>
            <artifactId>rampart-core</artifactId>
            <version>1.5.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.xalan</groupId>
                    <artifactId>xalan</artifactId>
            </exclusion>
                <exclusion>
                    <groupId>org.opensaml</groupId>
                    <artifactId>opensaml</artifactId>
            </exclusion>
                <exclusion>
                    <groupId>org.opensaml</groupId>
                    <artifactId>openws</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
            <scope>compile</scope>
    </dependency>
        <dependency>
            <groupId>org.apache.ws.commons.axiom</groupId>
            <artifactId>axiom-api</artifactId>
            <version>1.2.10</version>
            <scope>compile</scope>
    </dependency>
        <dependency>
            <groupId>xalan</groupId>
            <artifactId>xalan</artifactId>
            <version>2.7.1</version>
    </dependency>
        <dependency>
            <groupId>org.opensaml</groupId>
            <artifactId>opensaml</artifactId>
            <version>2.2.1</version>
            <exclusions>
                <exclusion>
                    <groupId>opensaml</groupId>
                    <artifactId>openws</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
        <dependency>
            <groupId>opensaml</groupId>
            <artifactId>openws</artifactId>
            <version>1.2.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.opensaml</groupId>
                    <artifactId>xmltooling</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
        <dependency>
            <groupId>org.opensaml</groupId>
            <artifactId>xmltooling</artifactId>
            <version>1.2.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bcprov-ext-jdk15</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-ext-jdk15</artifactId>
            <version>1.43</version>
    </dependency>

        <!-- PROVIDED DEPENDENCIES -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.3</version>
            <scope>provided</scope>
    </dependency>
</dependencies>

هل كانت مفيدة؟

المحلول

The rampart jars all declare xalan as a transitive dependency. From the error message:

Failed to collect dependencies at org.apache.rampart:rampart-trust:jar:1.5.1 -> org.apache.rampart:rampart-policy:jar:1.5.1 -> org.apache.xalan:xalan:jar:2.7.1

The last jar mentioned is the one Maven couldn't find.

For some reason the xalan artifact is not available under the group id org.apache.xalan (maybe it was at some point?). But it is available under the group id xalan. So the quick fix is to just exclude it from each of the rampart dependencies, and declare it yourself with the xalan group id.

    <dependency>
        <groupId>org.apache.rampart</groupId>
        <artifactId>rampart-trust</artifactId>
        <version>1.5.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.xalan</groupId>
                <artifactId>xalan</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.rampart</groupId>
        <artifactId>rampart-core</artifactId>
        <version>1.5.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.xalan</groupId>
                <artifactId>xalan</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>xalan</groupId>
        <artifactId>xalan</artifactId>
        <version>2.7.1</version>
    </dependency>

نصائح أخرى

In 2012 shibboleth migrated the location of his repository from http://shibboleth.internet2.edu/downloads/maven2/ to https://build.shibboleth.net/nexus/content/repositories/releases/ . However some pom files of recognized libraries like opensaml are referencing the same old location. The error is documented in this link where there are some important points:

  • if some artifact is looked in this location, it will return a web page with an informative message. What if maven is trying to locate a jar? you will get an html file in your local repo but with the name of the looked jar. Correct behavior would be that the server return an html status different than 200.

  • You would try to create a local libraries repository (using nexus, artifactory, etc...), but in the 1st time you need to load the libraries ....

Currently I needed to compile an old project with axis2 1.6.0 dependency that uses some security features for web services and I needed to compile an old project of the repository of the company, and I needed to find a solution. Solution implemented it's documented below:

  • Add a mapping in your etc/hosts file for the last location:

    '# redirect to a non existent url to discard artifacts of this repository:
    127.0.0.127     shibboleth.internet2.edu        
    
  • Add a settings.xml file inside your ~/.m2/ directory containing new repositories containig the jars, for example, wso2 repositories:

    ...

     <repository>
      <id>wso2-repository.central</id>
      <name>Wso2 Maven</name>
      <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
      <layout>default</layout>
     </repository>
     <repository>
      <id>maven2-repository.central</id>
      <name>Central Repository for Maven</name>
      <url>http://repo1.maven.org/maven2/</url>
      <layout>default</layout>
     </repository>
    
     <repository>
       <id>maven-repository.dev.java.net</id>
       <name>Java.net Repository for Maven 1</name>
       <url>http://download.java.net/maven/1/</url>
       <layout>default</layout>
     </repository>
     <repository>
       <id>maven2-repository.dev.java.net</id>
       <name>Java.net Repository for Maven 2</name>
       <url>http://download.java.net/maven/2/</url>
     </repository>
    
     <repository>
      <id>build.shibboleth.net</id>
      <name>Shibboleth.New</name>
      <url>https://build.shibboleth.net/nexus/content/repositories/releases/</url>
      <layout>default</layout>
     </repository>
    
     ...
    

I have experimented other solutions like exclude the releases and snapshots declarations or doing a inexistent-miror for the repository with problems with no luck

  <!--   

     <repository>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>        
      <id>shibboleth.internet2.edu</id>
      <name>Shibboleth.Old</name>
      <url>http://shibboleth.internet2.edu/downloads/maven2/</url>
      <layout>default</layout>
     </repository>
   -->

<!-- #region: disable shibboleth -->
<!--
<mirror>
  <id>shibboleth-release-disable</id>
  <name>DisbleShibboleth</name>
  <url>http://0.0.0.0/null</url>
  <mirrorOf>shibboleth-release</mirrorOf>
</mirror>
-->

Be free to experiment If it could help you.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top