CXF org.apache.cxf.BusException: No DestinationFactory was found for the namespace http://cxf.apache

在eclipse中使用cxf发布restful接口运行正常

打成jar包就报错

org.apache.cxf.service.factory.ServiceConstructionException
        at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:215)
        at com.tls.main.Main.start(Main.java:42)
        at com.tls.main.Main.main(Main.java:20)
Caused by: org.apache.cxf.BusException: No DestinationFactory was found for the namespace http://cxf.apache.org/transports/http.
        at org.apache.cxf.bus.managers.DestinationFactoryManagerImpl.getDestinationFactory(DestinationFactoryManagerImpl.java:122)
        at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:79)
        at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:63)
        at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:170)
        ... 2 more

解决办法:

用压缩软件打开jar,找到\META-INF\cxf\bus-extensions.txt

将你maven导入的cxf-rt-transports-http-jetty.jar和cxf-rt-transports-http.jar

把jar里面\META-INF\cxf\bus-extensions.txt内容拷贝到你打包的jar中

注意里面的回车可能是linux下的回车

不同版本的cxf,bus-extensions.txt里面的内容可能不一样

我用的是3.1.4

<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxrs</artifactId>
			<version>3.1.4</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxws</artifactId>
			<version>3.1.4</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-http-jetty</artifactId>
			<version>3.1.4</version>
		</dependency>

 我的bus-extensions.txt文件内容

org.apache.cxf.bus.managers.PhaseManagerImpl:org.apache.cxf.phase.PhaseManager:true
org.apache.cxf.bus.managers.WorkQueueManagerImpl:org.apache.cxf.workqueue.WorkQueueManager:true
org.apache.cxf.bus.managers.CXFBusLifeCycleManager:org.apache.cxf.buslifecycle.BusLifeCycleManager:true   	   
org.apache.cxf.bus.managers.ServerRegistryImpl:org.apache.cxf.endpoint.ServerRegistry:true
org.apache.cxf.bus.managers.EndpointResolverRegistryImpl:org.apache.cxf.endpoint.EndpointResolverRegistry:true
org.apache.cxf.bus.managers.HeaderManagerImpl:org.apache.cxf.headers.HeaderManager:true
org.apache.cxf.service.factory.FactoryBeanListenerManager::true
org.apache.cxf.bus.managers.ServerLifeCycleManagerImpl:org.apache.cxf.endpoint.ServerLifeCycleManager:true
org.apache.cxf.bus.managers.ClientLifeCycleManagerImpl:org.apache.cxf.endpoint.ClientLifeCycleManager:true
org.apache.cxf.bus.resource.ResourceManagerImpl:org.apache.cxf.resource.ResourceManager:true
org.apache.cxf.catalog.OASISCatalogManager:org.apache.cxf.catalog.OASISCatalogManager:true

org.apache.cxf.jaxrs.JAXRSBindingFactory::true
org.apache.cxf.transport.http_jetty.JettyDestinationFactory::true
org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory::true
org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProviderFactory:org.apache.cxf.transport.http.ContinuationProviderFactory:true

org.apache.cxf.transport.http.HTTPTransportFactory::true
org.apache.cxf.transport.http.HTTPWSDLExtensionLoader::true:true
org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder::true:true
org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder::true:true
org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider::true:true

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值