Pages

Thursday, October 20, 2011

The jaxws-maven-plugin

For sometime, I've been encountering an error in my JAX-WS application in Maven when deploying it to Websphere. The error occurs when your web service's return type is a List. Here's the exact error:

[javax.xml.bind.JAXBException: java.util.List is not known to this context]

Exporting the war file using IBM RAD will not let you encounter this problem. Unfortunately, RAD does not have a Maven plugin so we are using the native Eclipse IDE. So we've come up to a solution using the jaxws-maven-plugin to make sure the application will run properly in Websphere. Add this into your pom.xml :

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>2.2</version>
   <executions>
       <execution>
           <phase>generate-sources</phase>
           <goals>
               <goal>compile</goal>
           </goals>
      </execution>
   </executions>
   <configuration>
       <target>1.6</target>
       <source>1.6</source>
   </configuration>
</plugin>

<plugin>
    <groupid>org.codehaus.mojo</groupId>
    <artifactid>jaxws-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>wsgen</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <destdir>src/main/java</destDir>     
        <sei>ph.com.src.endpoint.WsEndpoint</sei>     
        <keep>true</keep>      
        <verbose>true</verbose>
    </configuration>
</plugin>

The <sei> should be the location & name of your service endpoint interface. It will I think sort of override it so that no error will occur. :)

No comments:

Post a Comment