0

I have set up Arquillian (Embedded GlassFish) for unit testing some features involving using web services.

When I run the test, I get the following exception stack: http://pastebin.com/BU1rpaCr

Looking at the StackTrace, the actual error seems to be this:

java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;

I think this is fixed by modifying the pom.xml properly, but I have not figured out how to do it properly.

This is what I have in 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>

It is using java 1.6. which may be some what connected into this (as what I understood from other similar posts). I am also rather new with Arquillian, but I have managed to do some working tests with it, so I do not think there should be much wrong with that. (Also this test class runs succesfully if I drop out the ws-calls)

Ville Myrskyneva
  • 1,560
  • 3
  • 20
  • 35

2 Answers2

1

This one looks like you've run into the problem involving the JAX-WS and JAXB APIs for embedded GlassFish. If you're using Java 1.6, you'll need to use the have these APIs as endorsed libraries.

If you want to avoid this (presumably because you'd using a managed GlassFish instance in production), then I'd recommend not using the embedded GlassFish container for testing. Your project POM would be simpler. And your tech stack used during tests would be more realistic since the APIs would be available in the right classloaders etc.

Vineet Reynolds
  • 76,006
  • 17
  • 150
  • 174
  • The production will be deployed on Web Logic actually, but it's presumably the same. I understand what you mean and will keep this in mind. However I believe I must have these configurations in the pom.xml and not to provide explicit documentation how to set up environment for testing. I haven't tested this on my development GF instance yet, but if I run to troubles with that, I must rethink again. – Ville Myrskyneva Nov 06 '13 at 07:51
0

The solution seems to be using the 'endorsed' libraries in this case. This must be achieved by using Maven instead manually copying the libraries into automatically 'endorsed' location(s).

This question seems to have the correct answer: How to specify the JAXB version in maven-jaxb2-plugin?

I had to do a minor modification. I used 2.1. versions in order to get this ok (same error when using 2.2).

<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>
Community
  • 1
  • 1
Ville Myrskyneva
  • 1,560
  • 3
  • 20
  • 35
  • This got me past the 'NoSuchMethodError'. Though I received another error (Connection timed out: connect). This is hopefully just some configuration error, but I think it is another issue anyway. – Ville Myrskyneva Nov 06 '13 at 07:41
  • And after few minutes I got the same error message again. 'Something' worked momentarily for sure, but this still keeps me puzzled. => Tried changing the versions (2.1.x <=> 2.2.x), but it had no effect. – Ville Myrskyneva Nov 06 '13 at 08:06