dev@jax-ws-commons.java.net

jaxws-maven-plugin thread synchronization

From: Elie Kassis <ekassis_at_hotmail.com>
Date: Tue, 24 Sep 2013 12:39:33 +0300

Hi,

 

I'm running a very large build using a CI server and I'm facing regular
failures when running in multithread maven plugin mode. (1 out of 10 builds
fail)

 

I tested patching jaxws-maven-plugin adding the below patch that fixed the
issue and I have 0 failures at the moment.

 

Can you please tell me how can I integrate this fix into the future versions
so I can maintain my compatibility with future releases?

 

Thank you.

 

<groupId>org.codehaus.mojo</groupId>

<artifactId>jaxws-maven-plugin</artifactId>

<version>1.10</version>

 

Index: src/main/java/org/codehaus/mojo/jaxws/AbstractWsGenMojo.java

===================================================================

--- src/main/java/org/codehaus/mojo/jaxws/AbstractWsGenMojo.java
(revision 1165)

+++ src/main/java/org/codehaus/mojo/jaxws/AbstractWsGenMojo.java
(working copy)

@@ -34,6 +34,7 @@

  * @version $Id: WsGenMojo.java 3169 2007-01-22 02:51:29Z dantran $

  */

abstract class AbstractWsGenMojo extends AbstractJaxwsMojo {

+ private static Object lock = new Object();

     /**

      * Specify that a WSDL file should be generated in ${resourceDestDir}

@@ -85,6 +86,8 @@

     public void execute()

         throws MojoExecutionException, MojoFailureException {

+ synchronized (lock) {

+

         init();

         // Need to build a URLClassloader since Maven removed it form the
chain

@@ -105,6 +108,7 @@

             Thread.currentThread().setContextClassLoader(parent);

             System.setProperty("java.class.path", orginalSystemClasspath);

         }

+ }

     }

     private void init() throws MojoExecutionException, MojoFailureException
{

Index: src/main/java/org/codehaus/mojo/jaxws/MainWsGenMojo.java

===================================================================

--- src/main/java/org/codehaus/mojo/jaxws/MainWsGenMojo.java (revision
1165)

+++ src/main/java/org/codehaus/mojo/jaxws/MainWsGenMojo.java (working copy)

@@ -10,6 +10,7 @@

  * @phase process-classes

  * @requiresDependencyResolution

  * @description generate JAX-WS wrapper beans.

+ * @threadSafe

  */

public class MainWsGenMojo extends AbstractWsGenMojo {

     /**

Index: src/main/java/org/codehaus/mojo/jaxws/MainWsImportMojo.java

===================================================================

--- src/main/java/org/codehaus/mojo/jaxws/MainWsImportMojo.java
(revision 1165)

+++ src/main/java/org/codehaus/mojo/jaxws/MainWsImportMojo.java
(working copy)

@@ -8,7 +8,8 @@

  * @goal wsimport

  * @phase generate-sources

  * @requiresDependencyResolution

- * @description JAXWS 2.x Plugin.

+ * @description JAXWS 2.x Plugin

+ * @threadSafe

  *

  * @author Kohsuke Kawaguchi

  */

Index: src/main/java/org/codehaus/mojo/jaxws/WsImportMojo.java

===================================================================

--- src/main/java/org/codehaus/mojo/jaxws/WsImportMojo.java
(revision 1165)

+++ src/main/java/org/codehaus/mojo/jaxws/WsImportMojo.java (working
copy)

@@ -34,6 +34,7 @@

  */

abstract class WsImportMojo extends AbstractJaxwsMojo

{

+ private static Object lock = new Object();

     /**

      * The package in which the source files will be generated.

@@ -175,7 +176,8 @@

     public void execute()

         throws MojoExecutionException

     {

-

+ synchronized (lock) {

+

         // Need to build a URLClassloader since Maven removed it form the
chain

         ClassLoader parent = this.getClass().getClassLoader();

         String originalSystemClasspath = this.initClassLoader( parent );

@@ -209,6 +211,7 @@

             Thread.currentThread().setContextClassLoader( parent );

             System.setProperty( "java.class.path", originalSystemClasspath
);

         }

+ }

     }

 

 

Regards,

Elie