I create a JAXRS server endpoint (CXF 3.5.2) using spring bean declarations

like:

     <jaxrs:server id="restServer" basePackages="xxx">

           <jaxrs:serviceBeans>

                <ref bean="TestApi" />

           </jaxrs:serviceBeans>

           <jaxrs:providers>

                <…/>

           </jaxrs:providers>

           <jaxrs:features>

                <… />

           </jaxrs:features>

           <jaxrs:inInterceptors>

                <… />

           </jaxrs:inInterceptors>

           <jaxrs:outInterceptors>*

                <**…**/>*

           </jaxrs:outInterceptors>*

     </jaxrs:server>





Here my “TestApi” bean interface is declared like:



      @Path("accounts")

       @Consumes(MediaType.*APPLICATION_JSON*)

       @Produces(MediaType.*APPLICATION_JSON*)

       public interface TestApi {

         …

       }



And CXF is triggered via a servlet configuration like:

     <servlet>

             <display-name>CXF Servlet</display-name>

             <servlet-name>CXFServlet</servlet-name>


<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>

       </servlet>

       <servlet-mapping>

             <servlet-name>CXFServlet</servlet-name>

             <url-pattern>/services/*</url-pattern>

       </servlet-mapping>





Because I’ve got the @Path declaration on the interface type I’ve omitted

the address=”accounts” attribute on the jaxrs:server declaration since
otherwise

I noticed that the server would be listening to /basepath/services/
accounts/accounts/…).



Now this configuration works perfectly, only when shutting down the
application server cxf calls

        ServerImpl#destroy()



which delegates (via Obeservable) to AbstractHTTPDestination#deactivate()
which calls

registry.removeDestination(path).

This path is null (no ‘address’ specified on jaxrs:server declaration) and
results in a NPE on the registry Map.

This causes an unclean shutdown of my server.



Is this an error in cxf or is my jaxrs:server configured incorrectly?

How does the ‘address’ attribute on the jaxrs:server declaration correctly
interact with the @Path parameter on the API interface?

Reply via email to