Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-8753

Spring-based auto-discovery of root resources and providers not working anymore

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.5.0, 3.5.1, 3.5.2, 3.5.3
    • None
    • JAX-RS
    • None
    • Unknown

    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="..."/>)

      CXF specification ---> https://cxf.apache.org/docs/jaxrs-services-configuration.html#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 &&)

      ...
      } 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)

      Attachments

        1. cxf-bug-test.7z
          1 kB
          Andrii Pitukh

        Activity

          People

            buhhunyx Alexey Markevich
            svignello serge vignello
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: