Web services Arquillian web服务测试-NoSuchMethodError

Web services Arquillian web服务测试-NoSuchMethodError,web-services,jboss-arquillian,Web Services,Jboss Arquillian,我已经设置了Arquillian(嵌入式GlassFish),用于单元测试一些涉及使用web服务的特性 运行测试时,我得到以下异常堆栈: 查看StackTrace,实际错误似乎是: java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String; 我认为通过正确修改pom.xml可以解决这个问题,但我还没有找到正确的方法 这是我在pom.xml中的内容: <?xml version="1

我已经设置了Arquillian(嵌入式GlassFish),用于单元测试一些涉及使用web服务的特性

运行测试时,我得到以下异常堆栈:

查看StackTrace,实际错误似乎是:

java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
我认为通过正确修改pom.xml可以解决这个问题,但我还没有找到正确的方法

这是我在pom.xml中的内容:

<?xml version="1.0" encoding="ISO-8859-1"?>
<project>

<parent>
    <groupId>xxx</groupId>
    <artifactId>super-pom</artifactId>
    <version>1.3</version>
</parent>

<modelVersion>4.0.0</modelVersion>

<groupId>xxx.ws</groupId>
<artifactId>wsclient</artifactId>
<packaging>jar</packaging>

<name>xxx: WEBSERVICE CLIENT</name>
<!-- Replace with a detailed description of the project. -->
<description>        
</description>

<version>1.0.1</version>


<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>${wls.jdk.version}</source>
                <target>${wls.jdk.version}</target>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <includes>
                    <include>**/*Test.java</include>
                </includes>
                <excludes>
                    <exclude>**/*IntegrationTest.java</exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-antrun-plugin</artifactId>
                                    <versionRange>[1.3,)</versionRange>
                                    <goals>
                                        <goal>run</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-bom</artifactId>
            <version>1.0.3.Final</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.extension</groupId>
        <artifactId>arquillian-persistence-impl</artifactId>
        <version>1.0.0.Alpha6</version>
        <exclusions>
            <exclusion>  <!-- declare the exclusion here -->
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
        </exclusions>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.8.4</version>
        <scope>test</scope>
    </dependency>
</dependencies>


<properties>
    <jira.project.key>xxx</jira.project.key>
    <vcs.module.path>https://svn.company.com/svn/zzz/yyy/trunk/xxx/parent/wsclient/</vcs.module.path>
    <env>dev</env>
    <wls.jdk.version>1.6</wls.jdk.version>
</properties>
    <profile>
        <id>arquillian-weld-ee-embedded</id>
        <dependencies>
            <dependency>
                <groupId>org.jboss.spec</groupId>
                <artifactId>jboss-javaee-6.0</artifactId>
                <version>1.0.0.Final</version>
                <type>pom</type>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-weld-ee-embedded-1.1</artifactId>
                <version>1.0.0.CR3</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.jboss.weld</groupId>
                <artifactId>weld-core</artifactId>
                <version>1.1.5.Final</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>1.6.4</version>
                <scope>test</scope>
            </dependency>
            <!-- Same error with and without this -->
            <dependency>
                <groupId>javax.xml.ws</groupId>
                <artifactId>jaxws-api</artifactId>
                <version>2.1-1</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </profile>

    <profile>
        <id>arquillian-glassfish-embedded</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <dependencies>
            <dependency>
                <groupId>org.jboss.arquillian.container</groupId>
                <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
                <version>1.0.0.CR3</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.glassfish.main.extras</groupId>
                <artifactId>glassfish-embedded-all</artifactId>
                <version>3.1.2</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
                <version>6.0</version>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    </profile>
</profiles>
</project>

xxx
超级聚甲醛
1.3
4.0.0
xxx.ws
wsclient
罐子
xxx:WEBSERVICE客户端
1.0.1
org.apache.maven.plugins
maven编译器插件
${wls.jdk.version}
${wls.jdk.version}
maven jar插件
试验罐
maven surefire插件
**/*Test.java
**/*IntegrationTest.java
org.eclipse.m2e
生命周期映射
1.0.0
org.apache.maven.plugins
maven antrun插件
[1.3,)
跑
org.jboss.arquillian
阿奎利安bom
1.0.3.1最终版本
进口
聚甲醛
朱尼特
朱尼特
4.11
测试
org.jboss.arquillian.junit
arquillian junit容器
测试
org.jboss.arquillian.extension
阿奎尔持久性
1.0.0.6
org.slf4j
slf4j api
测试
org.mockito
莫基托所有
1.8.4
测试
xxx
https://svn.company.com/svn/zzz/yyy/trunk/xxx/parent/wsclient/
发展
1.6
预埋arquillian焊缝
org.jboss.spec
jboss-javaee-6.0
1.0.0.1决赛
聚甲醛
假如
org.jboss.arquillian.container
arquillian-weld-ee-embedded-1.1
1.0.0.CR3
测试
org.jboss.weld
焊芯
1.1.5.最终版本
测试
org.slf4j
slf4j简单
1.6.4
测试
javax.xml.ws
JAXWSAPI
2.1-1
测试
阿基利安玻璃鱼
真的
org.jboss.arquillian.container
arquillian-glassfish-embedded-3.1
1.0.0.CR3
测试
org.glassfish.main.extras
玻璃鱼嵌入所有
3.1.2
假如
爪哇
JavaEEAPI
6
假如
它使用的是Java1.6,这可能与此相关(正如我从其他类似文章中了解的)。
我对Arquillian也相当陌生,但我已经设法用它做了一些工作测试,所以我认为这不会有太大的错误。(如果我退出ws调用,这个测试类也会成功运行)

这一个看起来像是您遇到了嵌入式GlassFish的JAX-WS和JAXB API的问题。如果您使用的是Java 1.6,则需要将这些API用作


如果您希望避免这种情况(可能是因为在生产中使用托管GlassFish实例),那么我建议不要使用嵌入式GlassFish容器进行测试。您的项目POM会更简单。测试期间使用的技术堆栈会更现实,因为API将在正确的类加载器中提供。在这种情况下,解决方案似乎使用了“认可的”库。这必须通过使用Mav来实现而是手动将库复制到自动“认可”的位置

这个问题似乎有正确的答案:

我必须做一个小的修改。我使用了2.1.versions来获得这个ok(使用2.2时出现相同的错误)


javax.xml.bind
jaxb api
2.1
罐子
com.sun.xml.bind
jaxb impl
2.1.16
罐子

这让我通过了“NoSuchMethodError”。尽管我收到了另一个错误(连接超时:connect)。这可能只是一些配置错误,但我认为这是另一个问题。几分钟后,我再次收到相同的错误消息。“某些东西”确实暂时起作用,但这仍然让我感到困惑。=>尝试更改版本(2.1.x 2.2.x),但它没有效果。产品实际上将部署在Web逻辑上,但可能是相同的。我理解您的意思,并将记住这一点。但是我相信我必须在pom.xml中有这些配置,而不是提供明确的文档
<artifactItems>
    <artifactItem>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.1</version>
        <type>jar</type>
    </artifactItem>
    <artifactItem>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.1.16</version>
        <type>jar</type>
    </artifactItem>
</artifactItems>