wsgen raising NoClassDefFoundError exceptions

牧云@^-^@ 提交于 2019-12-11 01:27:11

问题


I'm learning Java web services form the "Java Web Services Up and Running" book. As stated, I compiled the classes (where stands the "Teams" web service) :

javac ch01/team/*.java

Then, when it comes to generating artifacts with this command (done in the "ch01/team directory) :

wsgen -cp . ch01.team.Teams

I get the following error :

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)

Thank you for you help.


回答1:


Try to execute the wsgen command in the root directory of your application, not in the ch01/team directory. I think it should work, as you pass the package info in the command line.




回答2:


Based on answer @eternay gave, here is what worked for me:

 1. cd to project root directory
 2. issued wsgen -verbose -cp bin [package].ServiceImpl -wsdl
 3. "bin" being the root of .class files, and may be switched to "target" if you are using maven

I hope it will help someone.



来源:https://stackoverflow.com/questions/17074055/wsgen-raising-noclassdeffounderror-exceptions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!