Hi Jean,

Indeed, the jaxrs:server does not expect address to be omitted, you could use
the "/" (and I believe an empty string would also make it):

<jaxrs:server id="restServer" basePackages="xxx" address="/">
...
</jaxrs:server>


Thank you.
Hope it helps.

Best Regards,
    Andriy Redko
 

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

JPU> like:

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

JPU>            <jaxrs:serviceBeans>

JPU>                 <ref bean="TestApi" />

JPU>            </jaxrs:serviceBeans>

JPU>            <jaxrs:providers>

JPU>                 <…/>

JPU>            </jaxrs:providers>

JPU>            <jaxrs:features>

JPU>                 <… />

JPU>            </jaxrs:features>

JPU>            <jaxrs:inInterceptors>

JPU>                 <… />

JPU>            </jaxrs:inInterceptors>

JPU>            <jaxrs:outInterceptors>*

JPU>                 <**…**/>*

JPU>            </jaxrs:outInterceptors>*

JPU>      </jaxrs:server>





JPU> Here my “TestApi” bean interface is declared like:



JPU>       @Path("accounts")

JPU>        @Consumes(MediaType.*APPLICATION_JSON*)

JPU>        @Produces(MediaType.*APPLICATION_JSON*)

JPU>        public interface TestApi {

JPU>          …

JPU>        }



JPU> And CXF is triggered via a servlet configuration like:

JPU>      <servlet>

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

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


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

JPU>        </servlet>

JPU>        <servlet-mapping>

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

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

JPU>        </servlet-mapping>





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

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

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



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

JPU>         ServerImpl#destroy()



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

JPU> registry.removeDestination(path).

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

JPU> This causes an unclean shutdown of my server.



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

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

Reply via email to