部署WAR时出现AmbiguousResolutionException

时间:2015-08-17 15:40:04

标签: maven java-ee jax-rs resteasy

我在部署到WildFly 8.2.1时遇到了一个奇怪的错误,与Resteasy和maven设置有关。我已经失去了无数个小时的谷歌搜索无济于事 - 无法实例化MessageBodyReader
-AmbiguousResolutionException:WELD-001318:无法解决

之间的模糊依赖关系

项目组织:

-root  
-project  
--project-ear
--project-main
--project-rest
--project-jms

root pom.xml

<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>si.fri.liis.jmsprojekt</groupId>
    <artifactId>root</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

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

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.wildfly.bom</groupId>
                <artifactId>jboss-javaee-7.0-with-all</artifactId>
                <version>8.2.1.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-ejb-client-bom</artifactId>
                <version>8.2.0.Final</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>7.0</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-web-api</artifactId>
                <version>7.0</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.resteasy</groupId>
                <artifactId>resteasy-jaxrs</artifactId>
                <version>3.0.10.Final</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-ear-plugin</artifactId>
                    <version>2.10</version>
                    <configuration>
                        <version>7</version>
                        <defaultLibBundleDir>lib</defaultLibBundleDir>
                        <generateApplicationXml>true</generateApplicationXml>
                        <fileNameMapping>no-version</fileNameMapping>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-ejb-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <ejbVersion>3.2</ejbVersion>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                            </manifest>
                        </archive>
                        <generateClient>true</generateClient>
                        <clientIncludes>
                            <clientInclude>si/fri/liis/jmsprojekt/**/*SbRemote.class</clientInclude>
                            <clientInclude>si/fri/liis/jmsprojekt/**/*SbLocal.class</clientInclude>
                            <clientInclude>si/fri/liis/jmsprojekt/**/*Data.class</clientInclude>
                            <clientInclude>si/fri/liis/jmsprojekt/**/*Exception.class</clientInclude>
                        </clientIncludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                        <warName>jmsprojekt</warName>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>jaxb2-maven-plugin</artifactId>
                    <version>1.6</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

项目pom.xml

<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>
  <parent>
    <groupId>si.fri.liis.jmsprojekt</groupId>
    <artifactId>root</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../root/pom.xml</relativePath>
  </parent>

  <artifactId>jmsprojekt</artifactId>
  <packaging>pom</packaging>

    <modules>
        <module>jmsprojekt-ear</module>
        <module>jmsprojekt-main</module>
        <module>jmsprojekt-jms</module>
        <module>jmsprojekt-rest</module>
    </modules>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>si.fri.liis.jmsprojekt</groupId>
            <artifactId>jmsprojekt-main</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <type>ejb</type>
        </dependency>
        <dependency>
            <groupId>si.fri.liis.jmsprojekt</groupId>
            <artifactId>jmsprojekt-main</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <type>ejb-client</type>
        </dependency>
        <dependency>
            <groupId>si.fri.liis.jmsprojekt</groupId>
            <artifactId>jmsprojekt-jms</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <type>ejb</type>
        </dependency>
        <dependency>
            <groupId>si.fri.liis.jmsprojekt</groupId>
            <artifactId>jmsprojekt-rest</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <type>war</type>
        </dependency>
    </dependencies>
</dependencyManagement>
</project>

ear pom.xml

<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>
  <parent>
    <groupId>si.fri.liis.jmsprojekt</groupId>
    <artifactId>jmsprojekt</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <artifactId>jmsprojekt-ear</artifactId>
  <packaging>ear</packaging>

  <dependencies>
    <dependency>
        <groupId>si.fri.liis.jmsprojekt</groupId>
        <artifactId>jmsprojekt-main</artifactId>
        <type>ejb</type>
    </dependency>
    <dependency>
        <groupId>si.fri.liis.jmsprojekt</groupId>
        <artifactId>jmsprojekt-rest</artifactId>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>si.fri.liis.jmsprojekt</groupId>
        <artifactId>jmsprojekt-jms</artifactId>
        <type>ejb</type>
    </dependency>
  </dependencies>
</project>

休息pom.xml

<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>
  <parent>
    <groupId>si.fri.liis.jmsprojekt</groupId>
    <artifactId>jmsprojekt</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <artifactId>jmsprojekt-rest</artifactId>
  <packaging>war</packaging>

  <dependencies>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
        </dependency>
        <dependency>
            <groupId>si.fri.liis.jmsprojekt</groupId>
            <artifactId>jmsprojekt-main</artifactId>
            <type>ejb</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

WildFly部署日志,粘贴时间太长: http://pastebin.com/NK4eaba1

1 个答案:

答案 0 :(得分:3)

从您的链接日志中,看起来您包括resteasy两次,它可能来自您的“rest pom.xml”。看起来resteasy的依赖关系可能默认为compile范围。与java-ee的依赖性相同。这些都应该是provided范围。

  

引起:org.jboss.weld.exceptions.AmbiguousResolutionException:WELD-001318:无法解决之间的模糊依赖关系:      - 具有限定符[@Any @Default]的Managed Bean [class org.jboss.resteasy.plugins.providers.jaxb.JAXBXmlSeeAlsoProvider],      - 带有限定符的托管Bean [class org.jboss.resteasy.plugins.providers.jaxb.JAXBXmlSeeAlsoProvider] [@Any @Default]