问题
I am stuck since yesterday on this problem. I am using maven 2 on Windows:
Apache Maven 2.2.1 (r801777; 2009-08-06 20:16:01+0100)
And in my pom I use the plugin jaxws-maven-plugin as this :
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<wsdlFiles>
<wsdlFile>${basedir}/src/main/resources/MyService.wsdl
</wsdlFile>
</wsdlFiles>
<packageName>my.package.name</packageName>
</configuration>
</plugin>
When I run mvn compile I get the following error :
[INFO] jaxws:wsimport args: [-keep, -s, D:\myService\target\generated-sources\wsimport, -Xnocompile, -p, my.service.name, file:/D:/myService/src/main/resources/MyService.wsdl]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error executing: wsimport [-keep, -s, D:\myService\target\generated-sources\wsimport, -Xnocompile, -p, my.service.name, file:/D:/myService/src/main/resources/MyService.wsdl]
Embedded error: com/sun/tools/xjc/api/ErrorListener
com.sun.tools.xjc.api.ErrorListener
I tried :
- Adding a Windows env variable MAVEN_OPT with value "-Xmx768M -Xms768M -XX:PermSize=256m"
To launch wsimport myself, and it is working :
wsimport -keep -s D:\myService\target\generated-sources\wsimport -Xnocompile -p my.service.name file:/D:/myService/src/main/resources/MyService.wsdl
So anyone knows what could mean:
Embedded error: com/sun/tools/xjc/api/ErrorListener
com.sun.tools.xjc.api.ErrorListener
回答1:
Adding verbose logging for maven helped me : mvn -X compile I had in fact a :
Caused by: java.lang.NoClassDefFoundError: com/sun/tools/xjc/api/ErrorListener
at java.lang.ClassLoader.defineClass1(Native Method)
It is because one of my dependency is not in the Classpath.
回答2:
In case of
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/xjc/api/ErrorListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
at org.codehaus.mojo.jaxws.Invoker.main(Invoker.java:72)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.xjc.api.ErrorListener
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
it could be that you are using a JRE instead of a JDK as project (or default) Eclipse JRE
Reference: https://github.com/spring-guides/gs-consuming-web-service/issues/15#issuecomment-314018799
回答3:
This issue arises if you are trying to do mvn install from Eclipse. Try building from command line. Doing "mvn install" from CLI fixed the issue for me.
来源:https://stackoverflow.com/questions/18762318/jaxws-maven-plugin-fail-to-run-wsimport-errorlistener