You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Sergey Beryozkin <se...@iona.com> on 2008/09/16 13:22:08 UTC

Re: JAX-RS: Problems wiring beans in Spring

Hi

Adding

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

should help

Cheers, Sergey


> Hi, I'm trying to get CXF working with Spring 2.5.5.
>
> My tests now run, but I'm having problems starting the Jetty container
> to test the actual service.
>
> I have defined my service like this:
> @Path("/newsletter/")
> @ProduceMime("application/xml")
> @Component("newsletterService")
> public class NewsletterService {
> ...
> }
>
> And am trying to wire it into Spring with the following bean:
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       default-lazy-init="true"
>    xmlns:context="http://www.springframework.org/schema/context"
>    xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>    xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-2.5.xsd
> http://cxf.apache.org/jaxrs
> http://cxf.apache.org/schemas/jaxrs.xsd">
>  <import resource="classpath:META-INF/cxf/cxf.xml"/>
>  <import resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"/>
>  <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
>    <context:component-scan base-package="com.scanmine"/>
>    <jaxrs:server id="newsletterRest" address="/newsletter">
>        <jaxrs:serviceBeans>
>          <ref bean="newsletterService"/>
>        </jaxrs:serviceBeans>
>     </jaxrs:server>
> </beans>
>
> I am getting multiple errors:
> Initializing Spring root WebApplicationContext
> org.apache.cxf.BusException: No binding factory for namespace
> http://apache.org/cxf/binding/jaxrs registered.
>    at
> org.apache.cxf.binding.BindingFactoryManagerImpl.getBindingFactory(BindingFactoryManagerImpl.java:91)
>    at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.createBindingInfo(JAXRSServerFactoryBean.java:214)
>    at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.createEndpointInfo(JAXRSServerFactoryBean.java:194)
>    at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.createEndpoint(JAXRSServerFactoryBean.java:139)
>    at
> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:83)
>
>
> Also:
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'newsletterRest': Invocation of init method failed;
> nested exception is java.lang.NullPointerException
>    at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1336)
>
>
> I believe the last one is probably related to the first one.
>
> Any tips to how to get this working would be great.
>
> Kind regards,
> Tarjei

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Re: JAX-RS: Problems wiring beans in Spring

Posted by Tarjei Huse <ta...@scanmine.com>.
Sergey Beryozkin wrote:
> Hi
>
> Adding
>
> <import
> resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"/>
Slaps forehead.
Great.

Thanks a bundle for pointing out the obvious! I knew it was something
simple :)
Regards,
Tarjei
>
> should help
>
> Cheers, Sergey
>
>
>> Hi, I'm trying to get CXF working with Spring 2.5.5.
>>
>> My tests now run, but I'm having problems starting the Jetty container
>> to test the actual service.
>>
>> I have defined my service like this:
>> @Path("/newsletter/")
>> @ProduceMime("application/xml")
>> @Component("newsletterService")
>> public class NewsletterService {
>> ...
>> }
>>
>> And am trying to wire it into Spring with the following bean:
>> <beans xmlns="http://www.springframework.org/schema/beans"
>>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>       default-lazy-init="true"
>>    xmlns:context="http://www.springframework.org/schema/context"
>>    xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>>    xsi:schemaLocation="
>> http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>> http://www.springframework.org/schema/context
>> http://www.springframework.org/schema/context/spring-context-2.5.xsd
>> http://cxf.apache.org/jaxrs
>> http://cxf.apache.org/schemas/jaxrs.xsd">
>>  <import resource="classpath:META-INF/cxf/cxf.xml"/>
>>  <import
>> resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml"/>
>>  <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
>>    <context:component-scan base-package="com.scanmine"/>
>>    <jaxrs:server id="newsletterRest" address="/newsletter">
>>        <jaxrs:serviceBeans>
>>          <ref bean="newsletterService"/>
>>        </jaxrs:serviceBeans>
>>     </jaxrs:server>
>> </beans>
>>
>> I am getting multiple errors:
>> Initializing Spring root WebApplicationContext
>> org.apache.cxf.BusException: No binding factory for namespace
>> http://apache.org/cxf/binding/jaxrs registered.
>>    at
>> org.apache.cxf.binding.BindingFactoryManagerImpl.getBindingFactory(BindingFactoryManagerImpl.java:91)
>>
>>    at
>> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.createBindingInfo(JAXRSServerFactoryBean.java:214)
>>
>>    at
>> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.createEndpointInfo(JAXRSServerFactoryBean.java:194)
>>
>>    at
>> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.createEndpoint(JAXRSServerFactoryBean.java:139)
>>
>>    at
>> org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:83)
>>
>>
>>
>> Also:
>> org.springframework.beans.factory.BeanCreationException: Error creating
>> bean with name 'newsletterRest': Invocation of init method failed;
>> nested exception is java.lang.NullPointerException
>>    at
>> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1336)
>>
>>
>>
>> I believe the last one is probably related to the first one.
>>
>> Any tips to how to get this working would be great.
>>
>> Kind regards,
>> Tarjei
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland