cxf spring restful 问题解决(jar包冲突)

时间:2024-10-10 20:08:14

SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookservice': Invocation of init method failed; nested exception is org.apache.cxf.service.factory.ServiceConstructionException
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1422)
        .......

Caused by: org.apache.cxf.service.factory.ServiceConstructionException
        at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:201)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              ...

Caused by: java.lang.NullPointerException
        at org.apache.cxf.ws.discovery.listeners.WSDiscoveryServerListener.startServer(WSDiscoveryServerListener.java:64)
        at org.apache.cxf.bus.managers.ServerLifeCycleManagerImpl.startServer(ServerLifeCycleManagerImpl.java:61)
        at org.apache.cxf.endpoint.ServerImpl.start(ServerImpl.java:146)
        at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:192)
          ........

今天在做cxf spring restful框架的时候启动报这样的异常,查了很多资料

最后发现是jar包冲突造成的,此类日志的关键点在:NullPointException      冲突的jar包名称在一场causerd by 下面的第一行查看,对照引入的jar包核对

这个错误为cxf-services-ws-discovery-service-2.7.0.jar 这个jar包冲突导致

删除这个jar包就可以了