我们有一个使用Java 8的web服务,我们正在尝试升级到Java 11。
jaxws-ribinwsgen.bat (version "JAX-WS RI 4.0.0-M4 git-revision#ac6e723")显示以下异常:
Exception in thread "main" com.sun.xml.ws.model.RuntimeModelerException: A WebService annotation is not present on class: com.xxxxxx.security.services.webservice.SecurityServiceImpl
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:234)
at com.sun.xml.ws.db.DatabindingImpl.<init>(DatabindingImpl.java:70)
at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:51)
at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:28)
at com.sun.xml.ws.db.DatabindingFactoryImpl.createRuntime(DatabindingFactoryImpl.java:92)
at com.sun.tools.ws.wscompile.WsgenTool.buildModel(WsgenTool.java:247)
at com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:102)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.sun.tools.ws.Invoker.invoke(Invoker.java:132)
at com.sun.tools.ws.WsGen.main(WsGen.java:29)
Result: 1
但是,我们的SecurityServiceImpl.java类确实包含@Webservice注释,如下所示
import javax.jws.WebService;
@WebService(name="Foundation Security", serviceName="FoundationSecurityWS", portName="FoundationSecurityWSPort")
public class SecurityServiceImpl {
我们的ant构建脚本使用以下wsgen.bat参数:
<arg line="-cp ${wsgen.classpath.string}"/>
<arg line="-d ${build.webservice}/server"/>
<arg line="-s ${build.webservice}/serversource"/>
<arg line="-r ${build.webservice}/resource"/>
<arg line="-wsdl"/>
<arg line="-keep"/>
<arg line="com.xxxxxx.security.services.webservice.SecurityServiceImpl"/>
提前感谢您的建议
在JAX-WS com.sun.xml.ws.model中添加调试日志后。*,问题似乎是"导入javax.jws.WebService";需要更新为"import jakarta.jws.WebService;">