javaee / metro-jaxws-commons

Metro has been contributed to Eclipse Foundation. This repository is for legacy review only. Please refer to the Eclipse EE4J Metro project for the very latest
https://eclipse-ee4j.github.io/metro-wsit/
Other
10 stars 9 forks source link

jaxws-maven-plugin 2.3.1-b03 doesn't work with Maven >= 3.1.x #127

Open glassfishrobot opened 10 years ago

glassfishrobot commented 10 years ago

The modifications in #108 don't work anymore with Maven >= 3.1.x because Sonatype Aether was replaced with Eclipse aether. See also

The actual result is a NoClassDefFoundError when I use org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3.1-b03 (available at Maven Central repository) in combination with the recently released Maven 3.2.1:

$ mvn clean package
[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]         
[INFO] ------------------------------------------------------------------------
[INFO] Building myproject-common 2014.1.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myproject-common ---
[INFO] Deleting /home/thorsten/workspaces/myproject-common/target
[INFO] 
[INFO] --- jaxws-maven-plugin:2.3.1-b03:wsimport (default) @ myproject-common ---
[WARNING] Error injecting: org.jvnet.jax_ws_commons.jaxws.MainWsImportMojo
java.lang.NoClassDefFoundError: org/sonatype/aether/resolution/DependencyResolutionException
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2658)
    at java.lang.Class.getDeclaredConstructors(Class.java:2007)
    at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:245)
    at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:99)
(...)
Caused by: java.lang.ClassNotFoundException: org.sonatype.aether.resolution.DependencyResolutionException
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
    ... 54 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.471 s
[INFO] Finished at: 2014-03-17T11:57:49+01:00
[INFO] Final Memory: 9M/818M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3.1-b03:wsimport (default) on project myproject-common: Execution default of goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3.1-b03:wsimport failed: A required class was missing while executing org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3.1-b03:wsimport: org/sonatype/aether/resolution/DependencyResolutionException
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3.1-b03
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
(...)
**pom.xml**<plugin>
  <groupId>org.jvnet.jax-ws-commons</groupId>
  <artifactId>jaxws-maven-plugin</artifactId>
  <version>2.3.1-b03</version>
  <executions>
    <execution>
      <goals>
        <goal>wsimport</goal>
      </goals>
      <configuration>
        <wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
        <wsdlFiles>
          <wsdlFile>mywsdl.wsdl</wsdlFile>
        </wsdlFiles>
        <target>2.1</target>
        <wsdlLocation>/wsdl/mywsdl.wsdl</wsdlLocation>
      </configuration>
    </execution>
  </executions>
</plugin>

However, plugin versions 2.3 or older work.

Environment

Maven 3.2.1 Java 7u51, Java 8 b132 Solaris 11.1 x86_64

Affected Versions

[2.3.1]

glassfishrobot commented 10 years ago

Reported by t_heit

glassfishrobot commented 10 years ago

ahammar said: Dupe of #114

glassfishrobot commented 10 years ago

fschlier said: I created a patch with the migration to Eclipse Aether which resolves the issue. I used the most recent Aether version, but just version 3.1.1 of the Maven API's (3.2.2 is already available) to keep impact as small as possible.

Please review and push upstream if it's ok for you. Would be nice to see a promoted build in the repository soon.

**Aether migration patch**Index: pom.xml
===================================================================
--- pom.xml (revision 1185)
+++ pom.xml (working copy)
@@ -132,17 +132,17 @@
             <dependency>
 <groupId>org.apache.maven</groupId>
 <artifactId>maven-plugin-api</artifactId>
-<version>3.0.5</version>
+<version>3.1.1</version>
             </dependency>
             <dependency>
 <groupId>org.apache.maven</groupId>
 <artifactId>maven-core</artifactId>
-<version>3.0.5</version>
+<version>3.1.1</version>
             </dependency>
             <dependency>
 <groupId>org.codehaus.plexus</groupId>
 <artifactId>plexus-utils</artifactId>
-<version>3.0.10</version>
+<version>3.0.17</version>
             </dependency>
             <dependency>
 <groupId>org.apache.maven.plugin-tools</groupId>
@@ -159,17 +159,17 @@
             <dependency>
 <groupId>org.apache.maven</groupId>
 <artifactId>maven-settings</artifactId>
-<version>3.0.5</version>
+<version>3.1.1</version>
             </dependency>
             <dependency>
-<groupId>org.sonatype.aether</groupId>
+<groupId>org.eclipse.aether</groupId>
 <artifactId>aether-api</artifactId>
-<version>1.13.1</version>
+<version>1.0.0.v20140518</version>
             </dependency>
             <dependency>
-<groupId>org.sonatype.aether</groupId>
+<groupId>org.eclipse.aether</groupId>
 <artifactId>aether-util</artifactId>
-<version>1.13.1</version>
+<version>1.0.0.v20140518</version>
             </dependency>
         </dependencies>
     </dependencyManagement>
@@ -213,11 +213,11 @@
             <artifactId>maven-settings</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.sonatype.aether</groupId>
+            <groupId>org.eclipse.aether</groupId>
             <artifactId>aether-api</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.sonatype.aether</groupId>
+            <groupId>org.eclipse.aether</groupId>
             <artifactId>aether-util</artifactId>
         </dependency>
     </dependencies>
Index: src/main/java/org/jvnet/jax_ws_commons/jaxws/AbstractJaxwsMojo.java
===================================================================
--- src/main/java/org/jvnet/jax_ws_commons/jaxws/AbstractJaxwsMojo.java (revision 1185)
+++ src/main/java/org/jvnet/jax_ws_commons/jaxws/AbstractJaxwsMojo.java (working copy)
@@ -50,6 +50,7 @@
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
@@ -67,16 +68,16 @@
 import org.codehaus.plexus.util.cli.Commandline;
 import org.codehaus.plexus.util.cli.DefaultConsumer;
 import org.codehaus.plexus.util.cli.StreamConsumer;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.graph.DependencyFilter;
-import org.sonatype.aether.graph.DependencyNode;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.DependencyResolutionException;
-import org.sonatype.aether.resolution.DependencyResult;
-import org.sonatype.aether.util.filter.NotDependencyFilter;
-import org.sonatype.aether.util.graph.FilteringDependencyVisitor;
-import org.sonatype.aether.util.graph.PreorderNodeListGenerator;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.graph.DependencyNode;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.DependencyResolutionException;
+import org.eclipse.aether.resolution.DependencyResult;
+import org.eclipse.aether.util.filter.NotDependencyFilter;
+import org.eclipse.aether.util.graph.visitor.FilteringDependencyVisitor;
+import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator;

 /**
  *
@@ -409,8 +410,8 @@
     }

     private String[] getCP() throws DependencyResolutionException {
-        Set<org.sonatype.aether.artifact.Artifact> endorsedCp = new HashSet<org.sonatype.aether.artifact.Artifact>();
-        Map<String, org.sonatype.aether.artifact.Artifact> cp = new HashMap<String, org.sonatype.aether.artifact.Artifact>();
+        Set<org.eclipse.aether.artifact.Artifact> endorsedCp = new HashSet<org.eclipse.aether.artifact.Artifact>();
+        Map<String, org.eclipse.aether.artifact.Artifact> cp = new HashMap<String, org.eclipse.aether.artifact.Artifact>();
         Plugin p = pluginDescriptor.getPlugin();
         boolean toolsFound = false;
         for (Dependency d : p.getDependencies()) {
@@ -493,21 +494,21 @@
         return Os.isFamily(Os.FAMILY_WINDOWS);
     }

-    private StringBuilder getCPasString(Collection<org.sonatype.aether.artifact.Artifact> artifacts) {
+    private StringBuilder getCPasString(Collection<org.eclipse.aether.artifact.Artifact> artifacts) {
         StringBuilder sb = new StringBuilder();
-        for (org.sonatype.aether.artifact.Artifact a : artifacts) {
+        for (org.eclipse.aether.artifact.Artifact a : artifacts) {
             sb.append(a.getFile().getAbsolutePath());
             sb.append(File.pathSeparator);
         }
         return sb;
     }

-    private void sortArtifacts(DependencyResult result, Map<String, org.sonatype.aether.artifact.Artifact> cp, Set<org.sonatype.aether.artifact.Artifact> endorsedCp) {
+    private void sortArtifacts(DependencyResult result, Map<String, org.eclipse.aether.artifact.Artifact> cp, Set<org.eclipse.aether.artifact.Artifact> endorsedCp) {
         PreorderNodeListGenerator nlg = new PreorderNodeListGenerator();
         FilteringDependencyVisitor visitor = new FilteringDependencyVisitor(
 nlg, new NotDependencyFilter(new EndorsedFilter()));
         result.getRoot().accept(visitor);
-        for (org.sonatype.aether.artifact.Artifact a : nlg.getArtifacts(false)) {
+        for (org.eclipse.aether.artifact.Artifact a : nlg.getArtifacts(false)) {
             cp.put(a.getGroupId() + ":" + a.getArtifactId(), a);
         }

@@ -539,7 +540,7 @@

         @Override
         public boolean accept(DependencyNode node, List<DependencyNode> parents) {
-            org.sonatype.aether.artifact.Artifact a = node.getDependency().getArtifact();
+            org.eclipse.aether.artifact.Artifact a = node.getDependency().getArtifact();
             return !toExclude.contains(new Dep(a.getGroupId(), a.getArtifactId()));
         }

Index: src/main/java/org/jvnet/jax_ws_commons/jaxws/DependencyResolver.java
===================================================================
--- src/main/java/org/jvnet/jax_ws_commons/jaxws/DependencyResolver.java    (revision 1185)
+++ src/main/java/org/jvnet/jax_ws_commons/jaxws/DependencyResolver.java    (working copy)
@@ -20,18 +20,18 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import org.sonatype.aether.RepositorySystem;
-import org.sonatype.aether.RepositorySystemSession;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.collection.CollectRequest;
-import org.sonatype.aether.graph.Dependency;
-import org.sonatype.aether.graph.DependencyFilter;
-import org.sonatype.aether.graph.Exclusion;
-import org.sonatype.aether.repository.RemoteRepository;
-import org.sonatype.aether.resolution.DependencyRequest;
-import org.sonatype.aether.resolution.DependencyResolutionException;
-import org.sonatype.aether.resolution.DependencyResult;
-import org.sonatype.aether.util.artifact.DefaultArtifact;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.graph.Exclusion;
+import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.resolution.DependencyRequest;
+import org.eclipse.aether.resolution.DependencyResolutionException;
+import org.eclipse.aether.resolution.DependencyResult;
+import org.eclipse.aether.artifact.DefaultArtifact;

 /**
  *
Index: src/main/java/org/jvnet/jax_ws_commons/jaxws/EndorsedFilter.java
===================================================================
--- src/main/java/org/jvnet/jax_ws_commons/jaxws/EndorsedFilter.java    (revision 1185)
+++ src/main/java/org/jvnet/jax_ws_commons/jaxws/EndorsedFilter.java    (working copy)
@@ -18,9 +18,9 @@
 package org.jvnet.jax_ws_commons.jaxws;

 import java.util.List;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.DependencyFilter;
-import org.sonatype.aether.graph.DependencyNode;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.graph.DependencyNode;

 /**
  *
Index: src/main/java/org/jvnet/jax_ws_commons/jaxws/ExclusionFilter.java
===================================================================
--- src/main/java/org/jvnet/jax_ws_commons/jaxws/ExclusionFilter.java   (revision 1185)
+++ src/main/java/org/jvnet/jax_ws_commons/jaxws/ExclusionFilter.java   (working copy)
@@ -19,9 +19,9 @@

 import java.util.List;
 import org.apache.maven.model.Exclusion;
-import org.sonatype.aether.artifact.Artifact;
-import org.sonatype.aether.graph.DependencyFilter;
-import org.sonatype.aether.graph.DependencyNode;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.graph.DependencyNode;

 /**
  *
glassfishrobot commented 10 years ago

pic said: Hi, I got the problem during Eclipse Luna evaluation.

We are using Maven 3.0.5. Eclipse Luna use embedded Maven version for dependency resolution. (Maven 3.2.1)

During project import, the following error message appears in Eclipse :

Execution wsimport of goal org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3.1-b03:wsimport failed: 
A required class was missing while executing org.jvnet.jax-ws-commons:jaxws-maven-plugin:2.3.1-b03:wsimport: 
org/sonatype/aether/resolution/DependencyResolutionException

A promoted build in Maven repository would be very nice.

Thx and regards

glassfishrobot commented 9 years ago

lulseged said: Hi

When can a solution be available at least as a snapshot?

The latest in the snapshot under link below does not fix it.

https://maven.java.net/content/repositories/snapshots/org/jvnet/jax-ws-commons/jaxws-maven-plugin/2.3.1-SNAPSHOT/

BR Lulseged

glassfishrobot commented 9 years ago

hboutemy said: patch applied in revision 1186 you can build the plugin for yourself to test

the problem is that the plugin works now with Maven 3.1+ but not Maven 3.0.x

glassfishrobot commented 9 years ago

hboutemy said: IMHO, #108 should simply be reverted: using Aether just gives problems, when previous Maven code was working well AFAIK, and will continue in the future

was there a known problem related to #108? Or just the impression that Aether was the way to go (which is not always the case)?

glassfishrobot commented 10 years ago

Parent-Task: JAX_WS_COMMONS-108

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAX_WS_COMMONS-127