Hi Andriy,

Using address="/" seems to work but still I don't understand how the
following work together:
 - path specification in servlet mapping for the CXF servlet
(org.apache.cxf.transport.servlet.CXFServlet)
 - the 'address' attribute on the jaxrs:server bean declaration
 - the javax.ws.rs.Path or javax.jws.WebService annotation on the service
API description

Say I've two services with (relateive to the host) url's:
1. a jaxrs server  on url: '/<basePath>/services/service1'
2. a jaxws service endpoint on '/<basePath>/services/service2'

How do I configure above 3 aspects? Currently I have (working):
1.for the jaxrs:server endpoint:
        - servlet path mapping: '/services/*'
               - jaxrs-server address attribute: address="/"
               - @Path annotation: @Path("service1")
2.For the jaxws service endpoint:
        - servlet path mapping: '/services/*' (JAXWS and JAXRS requests are 
handleb
by the same CXF servle)
               - jaxws:endpoint server address attribute:
address="/service2"
               - @WebService(name="service2")

A correct request for '1' would be '/basePath>/services/service1/<ID>'.
A correct request for '2' would be '/basePath>/services/service2'.

The jaxrs/jaxws configuration behavior seem to differ with respect to:
        - the server address attribute
        - The API annotation (@Path or @Webservice)
The JAXWS server address attribute doesn't seem to interfere with the
@Webservice annotation. While the jaxrs server address attribute does seem
to interfere with the @Path annotation. I would have expected the jaxrs
server aspects to be configured as:
        - servlet path mapping: '/services/*'
               - jaxrs-server address attribute: address="/service1"
               - @Path annotation: @Path("service1")
but then a valid request would be
'/basePath>/services/service1/service1/<ID>'.

For both the 'address' attribute is relative to the servlet path.
The @Path Javadoc mentions that this path is relative to the ApplicationPath
which thus seems to be relative to the jaxrs-server address attribute. As
for @Webservice it doesnn't seem to be url-path related.

Question: Because now address="/" is set for the jaxrs:server will it also
inspect requests targeted for the jaxws service as those requests have start
with the same path '/<basePath>/services/...'.

Albeit somewhat confusing.

J.P.

-----Original Message-----
From: Andriy Redko <[email protected]>
Sent: dinsdag 14 juni 2022 1:08
To: Jean Pierre URKENS <[email protected]>;
[email protected]; [email protected]
Subject: Re: JAXRS server endpoint not gracefully shutdown

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
JPU> 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
JPU> -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
JPU> omitted

JPU> the address=”accounts” attribute on the jaxrs:server declaration
JPU> since 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
JPU> AbstractHTTPDestination#deactivate()
JPU> which calls

JPU> registry.removeDestination(path).

JPU> This path is null (no ‘address’ specified on jaxrs:server
JPU> declaration) and 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
JPU> correctly interact with the @Path parameter on the API interface?

Reply via email to