jaxws-maven-plugin无法运行wsimport(ErrorListener)

时间:2013-09-12 10:54:50

标签: java maven wsimport

我从昨天开始就遇到了这个问题。 我在Windows上使用maven 2:

Apache Maven 2.2.1 (r801777; 2009-08-06 20:16:01+0100)

在我的pom中,我使用插件jaxws-maven-plugin作为:

<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>

当我运行mvn compile时,我收到以下错误:

[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

我试过了:

  • 添加值为“-Xmx768M -Xms768M -XX:PermSize = 256m”的Windows env变量MAVEN_OPT
  • 要自己启动wsimport,它正在运行:

    wsimport -keep -s D:\myService\target\generated-sources\wsimport -Xnocompile -p my.service.name file:/D:/myService/src/main/resources/MyService.wsdl

所以任何人都知道可能意味着什么:

嵌入式错误:com / sun / tools / xjc / api / ErrorListener

com.sun.tools.xjc.api.ErrorListener

3 个答案:

答案 0 :(得分:1)

为maven添加详细日志帮助我:mvn -X compile 我其实是:

Caused by: java.lang.NoClassDefFoundError: com/sun/tools/xjc/api/ErrorListener
        at java.lang.ClassLoader.defineClass1(Native Method)

这是因为我的一个依赖项不在Classpath中。

答案 1 :(得分:1)

如果是

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

可能是您使用JRE而不是JDK作为项目(或默认)Eclipse JRE

参考:https://github.com/spring-guides/gs-consuming-web-service/issues/15#issuecomment-314018799

答案 2 :(得分:0)

如果您尝试从Eclipse安装mvn,则会出现此问题。尝试从命令行构建。通过CLI执行“ mvn install”可以为我解决此问题。