Friday, March 2, 2012

maven wsimport and deploy phase problem when behind a firewall

I did a client module that perform wsgen to get the WSDL from the server module and then the wsimport to create the client jar.

Everything works up to the install phase but fails in the deploy phase... the behavior is that mvn succed in uploading the jar but fails to upload the pom with the following error:

Failed to deploy artifacts: Could not find artifact ... in ...

To fix the problem it is required to unset the proxy when calling the wsimport goal with

<httpproxy>::</httpproxy>

as shown in the following pom:

<?xml version="1.0" encoding="UTF-8"?>

<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">
    <parent>
        <groupId>my.group</groupId>
        <artifactId>parent</artifactId>
        <version>0.1-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>my.group.ws</groupId>
    <artifactId>ws-client</artifactId>
    <version>0.1-SNAPSHOT</version>

    <name>WS client</name>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>my.group.ws</groupId>
            <artifactId>ws-server</artifactId>
            <version>0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.2.6</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>${project.build.directory}/generated-sources/wsimport</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArguments>
                        <endorseddirs>${project.build.directory}/endorsed</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <id>wsgen</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>wsgen</goal>
                        </goals>
                        <configuration>
                            <sei>my.group.ws.sei.SEIClass</sei>
                            <genWsdl>true</genWsdl>
                            <keep>false</keep>
                        </configuration>
                    </execution>
                    <execution>
                        <id>wsimport</id>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <wsdlDirectory>${project.build.directory}/generated-sources/wsdl</wsdlDirectory>
                            <sourceDestDir>${project.build.directory}/generated-sources/wsimport</sourceDestDir>
                            <keep>false</keep>
                            <httpproxy>::</httpproxy>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <excludes>
                        <exclude>my/group/ws/jaxws/*</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax.xml.bind</groupId>
                                    <artifactId>jaxb-api</artifactId>
                                    <version>2.2.4</version>
                                    <type>jar</type>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>javax.xml.ws</groupId>
                                    <artifactId>jaxws-api</artifactId>
                                    <version>2.2.8</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

No comments: