java - wsgen 引发 NoClassDefFoundError 异常

标签 java web-services wsgen

我正在通过“Java Web 服务启动和运行”一书学习 Java Web 服务。 如前所述,我编译了这些类(“Teams”Web 服务所在的位置):

javac ch01/team/*.java

然后,在使用此命令生成工件时(在“ch01/team 目录中完成)”:

wsgen -cp . ch01.team.Teams

我收到以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: Teams (wrong name: ch01/team/Teams)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at com.sun.tools.internal.ws.wscompile.WsgenOptions.getClass(WsgenOptions.java:276)
    at com.sun.tools.internal.ws.wscompile.WsgenOptions.validateEndpointClass(WsgenOptions.java:212)
    at com.sun.tools.internal.ws.wscompile.WsgenOptions.validate(WsgenOptions.java:203)
    at com.sun.tools.internal.ws.wscompile.WsgenTool.run(WsgenTool.java:111)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:111)
    at com.sun.tools.internal.ws.WsGen.main(WsGen.java:41)

谢谢你的帮助。

最佳答案

尝试在应用程序的根目录而不是 ch01/team 目录中执行 wsgen 命令。我认为它应该可以工作,因为您在命令行中传递包信息。

关于java - wsgen 引发 NoClassDefFoundError 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17074055/

相关文章:

java - 覆盖使用子类型的方法

java - 为什么有些资源文件放在META-INF目录下

java - 使用jdbc将android应用程序连接到mysql时捕获异常

php - prestashop api 1.6 webservice 更新订单状态

jax-ws - 难倒了 wsgen + maven 配置

java - 无法将 admob 代码添加到我的应用程序中?

web-services - Spring Security 与 REST Web 服务 - 使用 Curl 测试时无法通过 header 进行身份验证

java - 如何使用Servicemix使SOAP Web Services进行通信

java - wsgen ant 任务忽略@webMethod(exclude=true) 注解

jakarta-ee - 什么时候使用 wsgen?