我在ANT文件中使用wsgen定义类路径时遇到问题。

    <target name="wsgen">
    <property name="wsgen_cp" value="./build/classes/" />

    <echo message="classpath is : ${wsgen_cp}"/>
    <exec executable="wsgen">
        <!-- Classpath -->
        <arg value="-verbose" />
        <arg value="-classpath" />
        <arg value="${wsgen_cp}" />
        <!-- Sortie des sources -->
        <arg value="-d" />
        <arg value="${project.build.dir}/build/generated/"/>
        <arg value="-r" />
        <arg value="${project.build.dir}/build/wsdl"/>
        <arg value="-s" />
        <arg value="${project.build.dir}/build/sources"/>
        <!-- Classes de WebServices -->
        <arg value="-keep" />
        <arg value="rpm.patient.wsimpl.RpmPatientInterfaceImpl" />
    </exec>
</target>


运行目标后,会出现以下错误:

[exec] Exception in thread "main" java.lang.NoClassDefFoundError: rpm/patient/RpmPatientInterface
 [exec]     at java.lang.ClassLoader.defineClass1(Native Method)
 [exec]     at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
 [exec]     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
 [exec]     at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
 [exec]     at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
 [exec]     at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
 [exec]     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
 [exec]     at java.security.AccessController.doPrivileged(Native Method)
 [exec]     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
 [exec]     at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
 [exec]     at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
 [exec]     at com.sun.tools.internal.ws.wscompile.WsgenOptions.getClass(WsgenOptions.java:287)
 [exec]     at com.sun.tools.internal.ws.wscompile.WsgenOptions.validateEndpointClass(WsgenOptions.java:223)
 [exec]     at com.sun.tools.internal.ws.wscompile.WsgenOptions.validate(WsgenOptions.java:214)
 [exec]     at com.sun.tools.internal.ws.wscompile.WsgenTool.run(WsgenTool.java:110)
 [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [exec]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 [exec]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 [exec]     at java.lang.reflect.Method.invoke(Method.java:601)
 [exec]     at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:120)
 [exec]     at com.sun.tools.internal.ws.WsGen.main(WsGen.java:42)
 [exec] Caused by: java.lang.ClassNotFoundException: rpm.patient.RpmPatientInterface
 [exec]     at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
 [exec]     at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
 [exec]     at java.security.AccessController.doPrivileged(Native Method)
 [exec]     at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
 [exec]     at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
 [exec]     at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
 [exec]     ... 21 more


当我将相应的jar添加到我的类路径(位于rpm / Patient / RpmPatientInterface所在的位置)时:


似乎classpath无效,因为它找不到我要从中生成存根的文件:
[exec]找不到类:“ rpm.patient.wsimpl.RpmPatientInterfaceImpl”
[exec]用法:WSGEN [选项]

有什么提示对我有帮助吗?

最佳答案

我正在努力使用一个遗留系统,但我也不知道该如何生成WSDL。它包含Maven库,我必须在-cp参数中一一包含它们,我不能像java -cp lib/*命令那样使用通配符,不确定为什么。无论如何,以下希望对您有帮助:


D:\ MyData \ Software \ JavaJDK \ bin \ wsgen -verbose -keep -cp
“ spring-tx-4.0.2.RELEASE.jar; spring-web-4.0.2.RELEASE.jar; D:/ my-xxx-project / target / classes”
com.xxx.ws.webservice.xxxImpl -wsdl


我在target/lib路径中执行此操作,其中包含所有Maven罐子。 D:/my-xxx-project/target/classes包含所有Java类。

对于您的情况,您只需要在以下位置添加多个jar文件路径(用;分隔):


<property name="wsgen_cp" value="./build/classes/" />

10-07 23:06