• 解决CXF webService 调用报错: “Cannot create a secure XMLInputFactory”


    1. Nov 20, 2013 8:05:26 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
    2. INFO: Creating Service {http://webservices.server/}ExampleWebServiceService from class server.webservices.ExampleWebService
    3. Done creating client
    4. javax.xml.ws.soap.SOAPFaultException: Cannot create a secure XMLInputFactory
    5. at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:157)
    6. at $Proxy38.printString(Unknown Source)
    7. at ExampleNmsWebServiceClient.printString(ExampleNmsWebServiceClient.java:29)
    8. at ExampleNmsWebServiceClient.main(ExampleNmsWebServiceClient.java:40)
    9. Caused by: org.apache.cxf.binding.soap.SoapFault: Cannot create a secure XMLInputFactory
    10. at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:84)
    11. at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:51)
    12. at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:40)
    13. at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
    14. at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
    15. at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
    16. at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
    17. at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
    18. at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:835)
    19. at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1606)
    20. at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1502)
    21. at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1309)
    22. at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    23. at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:627)
    24. at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    25. at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
    26. at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
    27. at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
    28. at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
    29. at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
    30. at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    31. at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
    32. ... 3 more

    鸣谢:
    https://blog.csdn.net/u014644574/article/details/80024882

    https://blog.csdn.net/Apachezp/article/details/79590178
    https://www.codeleading.com/article/88993181106/

    原因:缺少woodstox-core-asl-4.4.1.jar和stax2-api-3.1.4.jar包。引入以后还报错说明这个jar包可能没有被有效加载,也许跟其他jar包有冲突。

    如果还是有报错,看项目中是否存在冲突包,并删除之。

    删除项目中的冲突的wstx-asl-3.2.1.jar包
    1:到JAVA_OPTIONS的-Dorg.apache.cxf.stax.allowInsecureParser=1

    2:重命名woodstox-core-asl-4.4.1.jar -> awoodstox-core-asl-4.4.1.jar

    在系统参数中 “org.apache.cxf.stax.allowInsecureParser” 不是 1 或者 true
    。找到临时解决方式,在接口类加载钱设置系统参数;

    @PostConstruct public void init() { //设置 cxf 转换为安全的 不然会报 错误 Cannot
    create a secure XMLInputFactory
    System.setProperty(StaxUtils.ALLOW_INSECURE_PARSER,Constant.STR_TRUE);
    }。
    原文链接:https://blog.csdn.net/Swear_fling/article/details/45232875

    https://blog.csdn.net/fan1989800/article/details/103181585
    通过intellij ide强大的Diagrams功能,查看依赖关系

    解决1 :尝试着添加排除项,如下到pom.xml中

    1. org.apache.neethi
    2. neethi
    3. org.codehaus.woodstox
    4. wstx-asl
    5. wsdl4j
    6. wsdl4j

    这次确实是解决了问题
    ————————————————

    https://cloud.tencent.com/developer/ask/sof/61623

    解决2 :

    1:到JAVA_OPTIONS的-Dorg.apache.cxf.stax.allowInsecureParser=1

    2:重命名woodstox-core-asl-4.4.1.jar -> awoodstox-core-asl-4.4.1.jar

     

  • 相关阅读:
    【ElasticSearch】基于 Java 客户端 RestClient 实现对 ElasticSearch 索引库、文档的增删改查操作,以及文档的批量导入
    5-Nacos环境搭建
    36.一文讲透JavaScript日期对象Date,时间戳、1970、date方法、date计算
    第18章_瑞萨MCU零基础入门系列教程之GPT
    7.Docker 常规软件安装
    【leetcode】【周赛】第 307 场
    第34讲:MySQL中常用的几种存储引擎以及如何选择
    二叉查找树
    ElasticSearch搭建集群详解
    Java开发:多线程编程
  • 原文地址:https://blog.csdn.net/qq_39900031/article/details/127935513