3
votes

I am trying to build a restful client using jaxrs:client as defined in http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml

In my test class I am getting org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.abc.service.ExportServiceTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bankbazaar.service.ExportService com.abc.service.ExportServiceTest.exportClient; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.abc.service.ExportService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=exportClient)}

this is my spring config

However

    exportClient=(ExportService)applicationContext.getBean("exportClient");

this works.

Thanks Himangshu

1
CXF uses its own injection mechanism if you dont define <context:annotation-config/> in your application context. If you have done this already please provide the applicationContext.xml. Otherwise it can be hard to tell what is going on.Rolf Thunbo

1 Answers

0
votes

The fully qualified classname for the two ExportService looks different com.abc.service.ExportService vs com.bankbazaar.service.ExportService. Fixing the two to point to the same name should fix the problem. Check the package name of the ExportService defined via applicationContext.getBean() to acertain the difference.