jaxws-maven-plugin fail to run wsimport (ErrorListener)

12,487

Solution 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 dependencies is not in the classpath.

Solution 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

Share:
12,487
Thomas
Author by

Thomas

//TODO

Updated on July 06, 2022

Comments

  • Thomas
    Thomas almost 2 years

    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
    
  • iChrome
    iChrome over 2 years
    What dependency have you added to your project?