[
https://issues.apache.org/jira/browse/CXF-8753?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17825602#comment-17825602
]
serge vignello commented on CXF-8753:
-------------------------------------
The way it should have worked from the beginning contradicts the CXF online
documentation :
[https://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-Auto-discoveryofrootresourcesandproviders]
_If you prefer doing a pure Spring-based auto-discovery you can have @Component
added to JAX-RS application classes and do_
_<jaxrs:server address="/customers"/>_
_<context:component-scan base-package="a.b.c"/>_
By the way - with the spring-based auto-discovery, the spring
{color:#FF0000}@Scope("prototype"){color}{color:#f9faf4}){color}annotation was
taken into account, with the _basePackages_ or _serviceAnnotationClass_
solution, it is not.
It seems i am stuck with a 3.4.x CXF version (except with a fork) to keep the
initial behaviour of our homemade tool generated applications ;-(
Regards
> 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.0, 3.5.1, 3.5.2, 3.5.3
> Reporter: serge vignello
> Assignee: Alexey Markevich
> Priority: Major
> Attachments: cxf-bug-test.7z
>
>
> *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}
>
> 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)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)