我想用java
命令直接運行WsImport。我正在使用以下命令(使用CLASSPATH環境設置):NoClassDefFoundError for otherwise available
$ java com.sun.tools.ws.WsImport -d /home/bence/NetBeansProjects/WebFormsTest/build/generated-sources/jax-ws -Xendorsed -keep -B-jaxb-facets -wsdl -r /home/bence/NetBeansProjects/WebFormsTest/build/generated-sources/jax-ws/resources -s /home/bence/NetBeansProjects/WebFormsTest/build/generated-sources/jax-ws -verbose org.czentral.test.service.AdminService
並在標題中獲取錯誤消息。與所有的細節:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/xjc/Plugin
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:1058)
at java.lang.ClassLoader.loadClass(ClassLoader.java:413)
at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
at com.sun.istack.tools.MaskingClassLoader.loadClass(MaskingClassLoader.java:82)
at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:363)
at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
at com.sun.tools.xjc.Options.findServices(Options.java:952)
at com.sun.tools.xjc.Options.getAllPlugins(Options.java:374)
at com.sun.tools.xjc.Options.parseArgument(Options.java:692)
at com.sun.tools.ws.wscompile.WsimportOptions.parseArguments(WsimportOptions.java:326)
at com.sun.tools.ws.wscompile.WsimportOptions.parseArguments(WsimportOptions.java:232)
at com.sun.tools.ws.wscompile.WsimportTool.parseArguments(WsimportTool.java:359)
at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:193)
at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.tools.ws.Invoker.invoke(Invoker.java:135)
at com.sun.tools.ws.WsImport.main(WsImport.java:57)
好吧,這遠遠合理的解釋是,從classpath中缺少.jar
。但事實上,我有權利罐子,這證實了以下內容:
$ java com.sun.tools.xjc.Plugin
Error: Main method not found in class com.sun.tools.xjc.Plugin, please define the main method as:
public static void main(String[] args)
因此類加載器實際上可以加載類。
什麼情況會導致這樣的錯誤?
謝謝,我很清楚除了這個例外。請閱讀我的問題的最後幾段。 – vbence