2

我无法在我的 Maven 项目上执行全新安装。这是一个旧的 Web 项目,我使用 Eclipse Kepler 的“转换为 Maven 项目”功能将其转换为 Maven。我正在使用 JDK 1.6,项目和工作区的合规性也设置为 1.6。将项目转换为 Maven 后,我开始配置 pom。这在大多数情况下都很好。

不幸的是,一旦我部署到本地 Tomcat 3.0.36 服务器,在运行时,我发现更多错误表明缺少 Jars;这是意料之中的,缺少的两个被添加到 pom 中。一旦将这两个 jars 添加到 pom 中,我就无法构建,因为 Maven 说由于未经授权,它无法将依赖项从 Maven 的中央存储库转移到我的本地存储库。

我的配置中没有设置代理,而且我几乎可以肯定我不需要设置它们,特别是因为我可以检索其他依赖项及其元数据,而不是这两个罐子。我确实在我的 Maven 设置中配置了一个镜像,就像中央超载时的备份一样。

有谁知道这里发生了什么?是否与错误日志中的“shibboleth”URL 有关?我是否需要排除所有壁垒依赖项并手动将它们添加到 POM 中?

错误日志:

[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

这是我的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>

4

2 回答 2

1

壁垒 jar 都将 xalan 声明为传递依赖项。从错误消息中:

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

提到的最后一个罐子是 Maven 找不到的。

由于某种原因,该xalan工件在组 ID 下不可用org.apache.xalan(也许它在某个时候?)。但它在 group id 下可用xalan。因此,快速解决方法是将其从每个壁垒依赖项中排除,并使用xalan组 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>
于 2013-10-31T16:01:38.087 回答
0

2012 年,shibboleth 将其存储库的位置从 http://shibboleth.internet2.edu/downloads/maven2/迁移到https://build.shibboleth.net/nexus/content/repositories/releases/。然而,一些公认的库(如 opensaml)的 pom 文件引用了相同的旧位置。该错误记录在此链接中,其中有一些要点:

  • 如果在此位置查看某些工件,它将返回一个带有信息性消息的网页。如果 maven 试图定位一个罐子怎么办?您将在本地 repo 中获得一个 html 文件,但带有查看的 jar 的名称。正确的行为是服务器返回不同于 200 的 html 状态。

  • 您会尝试创建一个本地库存储库(使用 nexus、artifactory 等...),但在第一次您需要加载库...。

目前我需要编译一个带有axis2 1.6.0依赖的旧项目,它使用了一些Web服务的安全功能,我需要编译一个公司存储库的旧项目,我需要找到一个解决方案。解决方案已实现,记录如下:

  • 在您的 etc/hosts 文件中为最后一个位置添加一个映射:

    '# 重定向到不存在的 url 以丢弃此存储库的工件:
    127.0.0.127 shibboleth.internet2.edu        
    
  • 在 ~/.m2/ 目录中添加一个 settings.xml 文件,其中包含包含 jar 的新存储库,例如 wso2 存储库:

    ...

     <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>
    
     ...
    

我已经尝试过其他解决方案,例如排除发布和快照声明或为存储库做一个不存在的镜像,但没有运气

  <!--   

     <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>
-->

如果它可以帮助你,请自由尝试。

于 2014-12-18T22:37:59.070 回答