serge vignello created CXF-8753:
-----------------------------------
Summary: Spring-based auto-discovery of root resources and
providers not working anymore
Key: CXF-8753
URL: https://issues.apache.org/jira/browse/CXF-8753
Project: CXF
Issue Type: Bug
Components: JAX-RS
Affects Versions: 3.5.3, 3.5.2, 3.5.1, 3.5.0
Reporter: serge vignello
*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|https://github.com/apache/cxf/commit/a06d00066c88077a1cf25766b841bd8f6cabb027#diff-37acd7d8c2c05b5986004f0a41bfcbc603e49ed1d03f9081727ae7223c7e0e7e]
commit breaks spring-based autodiscovery of jaxrs resources
(<context:component-scan base-package="..."/>)
[CXF specification --->
https://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-Auto-discoveryofrootresourcesandproviders|#JAXRSServicesConfiguration-Auto-discoveryofrootresourcesandproviders]
--> _org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java_
discoverContextResources(serviceAnnotationClass) method is no more triggered
when serviceAnnotationClass is null (due to condition change : || replaced by
&&)
{code:java}
...
} else if (serviceAnnotationClass != null && !serviceBeansAvailable &&
!providerBeansAvailable && !resourceProvidersAvailable)
{discoverContextResources(serviceAnnotationClass);}
...
{code}
Example :
*A. Spring configuration [beans.xml] --> :*
{code:java}
<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>
{code}
*{*}B. Class / Jaxrs resource not discovered anymore (it was ok with
cxf-3.4.8){*}*
{code:java}
// 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...
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)