代码之家  ›  专栏  ›  技术社区  ›  cen

部署WAR时出现歧义ResolutionException

  •  0
  • cen  · 技术社区  · 10 年前

    我在部署到WildFly8.2.1时遇到了一个奇怪的错误,这与Resteasy和maven设置有关。我花了无数个小时在网上搜索,但都没有用。
    -无法实例化MessageBodyReader
    -AmbiguousResolutionException:WELD-001318:无法解析

    项目组织:

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

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

    耳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 回复  |  直到 10 年前
        1
  •  5
  •   Jason Holmberg    10 年前

    从链接的日志中,您似乎包括 resteasy 两次,它可能来自“rest pom.xml”。它看起来像依赖于 重口味的 可能存在违约 compile 范围与依赖项相同 java-ee 。这两个都应该是 provided 范围

    由:org.jboss.weld.exceptions引起。AmbiguousResolutionException:WELD-001318:无法解析以下项之间的不明确依赖关系: -带有限定符[@Any@Default]的托管Bean[class org.jboss.restiasy.plugin.providers.jaxb.JAXBXmlSeeAlsoProvider], -带有限定符[@Any@Default]的托管Bean[class org.jboss.restiasy.plugin.providers.jaxb.JAXBXmlSeeAlsoProvider]