Details
Description
Since CXF-3.5.0 Spring-based auto-discovery of root resources and providers is not working anymore.
It seems that amarkevich org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java commit breaks spring-based autodiscovery of jaxrs resources (<context:component-scan base-package="..."/>)
--> org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
discoverContextResources(serviceAnnotationClass) method is no more triggered when serviceAnnotationClass is null (due to condition change : || replaced by &&)
... } else if (serviceAnnotationClass != null && !serviceBeansAvailable && !providerBeansAvailable && !resourceProvidersAvailable) {discoverContextResources(serviceAnnotationClass);} ...
Example :
A. Spring configuration [beans.xml] --> :
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:context="http://www.springframework.org/schema/context" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"> <jaxrs:server id="rest" address="/" transportId="http://cxf.apache.org/transports/http"/> <context:component-scan base-package="local.test"/> </beans>
B. Class / Jaxrs resource not discovered anymore (it was ok with cxf-3.4.8)
// Package package local.test; // Imports ... @Component @Scope("prototype") @Path("/rest") @Api(value = "REST1") @Produces(\{"application/xml", "application/json"}) @Consumes(\{"application/xml", "application/json"}) public class REST1AdeliaService...
Webapp failed to start :
--> Caused by: org.apache.cxf.service.factory.ServiceConstructionException: No resource classes found
at org.apache.cxf.jaxrs.AbstractJAXRSFactoryBean.checkResources(AbstractJAXRSFactoryBean.java:318)
at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:156)