Java 11下使用CXF的类强制转换异常

时间:2018-11-23 14:53:28

标签: java cxf

我正在将一个在Java 8下运行的应用程序转换为Java11。它使用Apache CXF库用于带有附件的Web服务。由于企业库已从11个JRE中删除,因此我已将所需的库添加到类路径(SAAJ,JAXB等)中。现在,当它运行时,我得到以下异常

    java.lang.ClassCastException: class com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to class javax.xml.soap.SOAPElement (com.sun.org.apache.xerces.internal.dom.ElementNSImpl is in module java.xml of loader 'bootstrap'; javax.xml.soap.SOAPElement is in unnamed module of loader 'app')
at org.apache.cxf.binding.soap.saaj.SAAJStreamWriter.adjustOverlaidNode(SAAJStreamWriter.java:64)
at org.apache.cxf.staxutils.OverlayW3CDOMStreamWriter.writeStartElement(OverlayW3CDOMStreamWriter.java:132)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:122)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:81)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:61)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:463)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:366)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:133)
at com.sun.proxy.$Proxy261.dpSrequestToken(Unknown Source)

有人知道为什么默认的消息构造会出现,以创建未实现所需SOAPElement接口的类的实例吗?

1 个答案:

答案 0 :(得分:0)

请等待CXF 3.3.x使用Java11。社区目前正在使用它。您可以使用JIRA https://issues.apache.org/jira/issues/?jql=project%20%3D%20CXF%20AND%20text%20~%20%22jdk11%22%20ORDER%20BY%20priority%20DESC%2C%20updated%20DESC来跟踪状态。