CXF JAX-RS is causing BusException

2019-07-24 14:42发布

问题:

After adding a RESTFul service using Apache CXF to my Spring (and Wicket) project I get the following exception:

org.apache.cxf.BusException: No binding factory for namespace http://apache.org/cxf/binding/jaxrs registered.

I have included the row below in my Spring configuration and thought this would actually solve my problem. But it did not.

import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"

Any feedback regarding how to solve this problem or ideas in what areas to look for a solution would be greately appreciated.

I am using Spring 3.0.0.RC2 and Apache CXF 2.2.5. (Maven dependencies to org.springframework.core, org.springframework.test, org.springframework.orm, org.springframework.web and cxf-bundle.)

Thanks in advance.

回答1:

Really I solved the problem by simply importing the resource you mentioned in the main application-context.xml file:

<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />

I use Spring 4.1.0.RELEASE and cxf 2.2.3.

In past, when I was using Spring 3.0 and Apacy CXF 2.2.2 I did not need to import this file. But now I have the following situation in the main application-context.xml file:

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />

and it works fine for me.



回答2:

Problem was resolved by downgrading Spring to version 2.5.6.



回答3:

I had the same problem. I have these three jars as dependency in my pom.xml

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-databinding-aegis</artifactId>
        <version>${cxf.version}</version>
    </dependency>

My problem was resolved by deleting these dependecies.