cxf报错No binding factory for namespace http://schemas.xmlsoap.org/soap/ registered问题解决

使用cxf实现的webservice在eclipse中运行时无问题,打包成jar后控制台运行报错(也是我上一篇文章里介绍的那个程序遗留下来的问题)

十月 30, 2020 3:12:42 下午 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://test/}Dny from class test.Dny
Exception in thread "main" org.apache.cxf.service.factory.ServiceConstructionException: Could not resolve a binding for null
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createBindingInfo(AbstractWSDLBasedEndpointFactory.java:361)
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpointInfo(AbstractWSDLBasedEndpointFactory.java:268)
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:146)
        at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:168)
        at test.Main.main(Main.java:11)
Caused by: org.apache.cxf.BusException: No binding factory for namespace http://schemas.xmlsoap.org/soap/ registered.
        at org.apache.cxf.bus.managers.BindingFactoryManagerImpl.getBindingFactory(BindingFactoryManagerImpl.java:93)
        at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createBindingInfo(AbstractWSDLBasedEndpointFactory.java:348)
        ... 4 more

上网搜索了下相关帖子,有几个解决方案,然而我这程序就是一个很普通的java程序,java -jar test.jar执行,除了cxf没有用任何框架,没有springboot,也不是java web,更不存在pom.xml这种maven程序才有的东西,所以没办法照着网上的做法在xml配置文件里修改。

不过看了几篇帖子也是有启发的,有个解决方案是maven程序在pom.xml里改编译器,恰好我之前接触过这种解决方案,虽然没用过,我先前写过的帖子里,Elasticsearch程序也是这样只有打包后才报错。

总之深思熟虑过后,我个人认为这次问题就是出在编译器里边,eclipse自带的编译功能会把同路径同名配置文件覆盖掉(或者说同路径同名文件只加载第一个出现的文件?之前Elasticsearch程序现在仔细想也可能就是这个原因),当程序里使用到相关配置时就报错了。

解决方法就是将所有冲突文件复制出来人工合并后再编译:

1.打开cxf-core-3.4.0.jar、cxf-rt-bindings-soap-3.4.0.jar、cxf-rt-transports-http-3.4.0.jar、cxf-rt-transports-http-jetty-3.4.0.jar、cxf-rt-wsdl-3.4.0.jar的META-INF\cxf\bus-extensions.txt文件。

2.在项目src下创建META-INF\cxf\bus-extensions.txt,将上边打开的文件内容都复制到这个文件里。

3.编译生成jar,打开该jar后可以发现该文件使用的是我合并后的文件。

问题解决。

 

以后这种类似的打包报错问题可以优先考虑一下是否同名文件冲突。

  • 6
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值