我们的项目正在从JDK8升级到JDK11。 用Ant生成WSDL时,出现错误。 我已经为此工作了几天,但是没有找到任何解决方案。
<path id="wsgen.main.classpath">
<fileset dir="${dir.externalLib}/jaxws-ri2.3.0/lib">
<include name="**/*.jar" />
</fileset>
</path>
...
<target name="generate_linux_wsdl">
<delete dir="${dir.temp}/WSDL"/>
<mkdir dir="${dir.temp}/WSDL"/>
<java classname="com.sun.tools.ws.WsGen">
<arg value="-d"/>
<arg value="${dir.temp}/WSDL"/>
<arg value="-r"/>
<arg value="${dir.temp}/WSDL"/>
<arg value="-cp"/>
<arg value="${wsgen.linux.classpathforrps}"/>
<arg value="${linux.serviceimpl.class}"/>
<arg value="-wsdl"/>
<arg value="-servicename"/>
<arg value="${linux.service.name}"/>
<classpath refid="wsgen.main.classpath"/>
</java>
</target>
这是ant文件。
[java] java.lang.RuntimeException: java.lang.annotation.IncompleteAnnotationException: javax.jws.WebService missing element name
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:861)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:231)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
[java] at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(UnknownSource)
[java] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
[java] at org.apache.tools.ant.Task.perform(Task.java:350)
[java] at org.apache.tools.ant.Target.execute(Target.java:449)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:470)
[java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
[java] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[java] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:437)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
[java] at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(UnknownSource)
[java] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
[java] at org.apache.tools.ant.Task.perform(Task.java:350)
[java] at org.apache.tools.ant.Target.execute(Target.java:449)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:470)
[java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
[java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:834)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:223)
[java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
[java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
[java] Caused by: java.lang.RuntimeException: java.lang.annotation.IncompleteAnnotationException: javax.jws.WebService missing element name
[java] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:163)
[java] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
[java] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
[java] at com.sun.tools.ws.wscompile.WsgenTool.buildModel(WsgenTool.java:197)
[java] at com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:128)
[java] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[java] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[java] at com.sun.tools.ws.Invoker.invoke(Invoker.java:153)
[java] at com.sun.tools.ws.WsGen.main(WsGen.java:56)
[java] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[java] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:218)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:155)
[java] ... 32 more
[java] Caused by: java.lang.annotation.IncompleteAnnotationException: javax.jws.WebService missing element name
[java] at java.base/sun.reflect.annotation.AnnotationInvocationHandler.invoke(AnnotationInvocationHandler.java:83)
[java] at com.sun.proxy.$Proxy1.name(Unknown Source)
[java] at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.visitType(WebServiceVisitor.java:144)
[java] at com.sun.tools.ws.processor.modeler.annotation.WebServiceVisitor.visitType(WebServiceVisitor.java:82)
[java] at jdk.compiler/com.sun.tools.javac.code.Symbol$ClassSymbol.accept(Symbol.java:1447)
[java] at com.sun.tools.ws.processor.modeler.annotation.WebServiceAp.process(WebServiceAp.java:188)
[java] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:972)
[java] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:888)
[java] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1214)
[java] at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1326)
[java] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258)
[java] at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:936)
[java] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
[java] at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
[java] ... 48 more
[java] Java Result: -1
我不知道错误在哪里。 我可以确认此ant任务正在jdk8中工作。升级到jdk11后,我包含了jaxws-ri2.3.0