Hi Jean,
JPU> 1. a jaxrs server on url: '/<basePath>/services/service1'
Correct, so in the relative form like address="/<something>", the JAX-RS
endpoint path would be:
<baseUrl>/<servlet path mapping>/<address>/[@ApplicationPath]/[@Path]
The @ApplicationPath is optional in this case.
JPU> 2. a jaxws service endpoint on '/<basePath>/services/service2'
The JAX-WS is very different from JAX-RS, essentially the action
comes inside the SOAP message behind <baseUrl>/<servlet path mapping>/
(@Path / @ApplicationPath are not relevant there).
JPU> Question: Because now address="/" is set for the jaxrs:server will it also
JPU> inspect requests targeted for the jaxws service as those requests have
start
JPU> with the same path '/<basePath>/services/...
This is a good question, I have not done it myself but I think it should work:
the servlet dispatches according to registered services, in this regard JAX-RS
and
JAX-WS should not conflict. Does it work in your case? Thank you.
Best Regards,
Andriy Redko
JPU> Hi Andriy,
JPU> Using address="/" seems to work but still I don't understand how the
JPU> following work together:
JPU> - path specification in servlet mapping for the CXF servlet
JPU> (org.apache.cxf.transport.servlet.CXFServlet)
JPU> - the 'address' attribute on the jaxrs:server bean declaration
JPU> - the javax.ws.rs.Path or javax.jws.WebService annotation on the service
JPU> API description
JPU> Say I've two services with (relateive to the host) url's:
JPU> 1. a jaxrs server on url: '/<basePath>/services/service1'
JPU> 2. a jaxws service endpoint on '/<basePath>/services/service2'
JPU> How do I configure above 3 aspects? Currently I have (working):
JPU> 1.for the jaxrs:server endpoint:
JPU> - servlet path mapping: '/services/*'
JPU> - jaxrs-server address attribute: address="/"
JPU> - @Path annotation: @Path("service1")
JPU> 2.For the jaxws service endpoint:
JPU> - servlet path mapping: '/services/*' (JAXWS and JAXRS requests
are handleb
JPU> by the same CXF servle)
JPU> - jaxws:endpoint server address attribute:
JPU> address="/service2"
JPU> - @WebService(name="service2")
JPU> A correct request for '1' would be '/basePath>/services/service1/<ID>'.
JPU> A correct request for '2' would be '/basePath>/services/service2'.
JPU> The jaxrs/jaxws configuration behavior seem to differ with respect to:
JPU> - the server address attribute
JPU> - The API annotation (@Path or @Webservice)
JPU> The JAXWS server address attribute doesn't seem to interfere with the
JPU> @Webservice annotation. While the jaxrs server address attribute does seem
JPU> to interfere with the @Path annotation. I would have expected the jaxrs
JPU> server aspects to be configured as:
JPU> - servlet path mapping: '/services/*'
JPU> - jaxrs-server address attribute: address="/service1"
JPU> - @Path annotation: @Path("service1")
JPU> but then a valid request would be
'/basePath>>/services/service1/service1/<ID>'.
JPU> For both the 'address' attribute is relative to the servlet path.
JPU> The @Path Javadoc mentions that this path is relative to the
ApplicationPath
JPU> which thus seems to be relative to the jaxrs-server address attribute. As
JPU> for @Webservice it doesnn't seem to be url-path related.
JPU> Question: Because now address="/" is set for the jaxrs:server will it also
JPU> inspect requests targeted for the jaxws service as those requests have
start
JPU> with the same path '/<basePath>/services/...'.
JPU> Albeit somewhat confusing.
JPU> J.P.
JPU> -----Original Message-----
JPU> From: Andriy Redko <[email protected]>
JPU> Sent: dinsdag 14 juni 2022 1:08
JPU> To: Jean Pierre URKENS <[email protected]>;
JPU> [email protected]; [email protected]
JPU> Subject: Re: JAXRS server endpoint not gracefully shutdown
JPU> Hi Jean,
JPU> Indeed, the jaxrs:server does not expect address to be omitted, you could
JPU> use the "/" (and I believe an empty string would also make it):
JPU> <jaxrs:server id="restServer" basePackages="xxx" address="/"> ...
JPU> </jaxrs:server>
JPU> Thank you.
JPU> Hope it helps.
JPU> Best Regards,
JPU> 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?