Not sure if that helps because there have been years passed when I was fiddling 
with these things.

So I think I have managed to setup a jax-rs service without spring 
configuration back in the day,

The configuration happens in war/web.xml

The trick is to use the CXFNonSpringJaxrsServlet

More info here: 
https://cxf.apache.org/docs/jaxrs-services-configuration.html#JAXRSServicesConfiguration-WithCXFNonSpringJaxrsServlet

Below are parts of my web.xml. In your position I would start from a very 
simple HelloWorld ServiceClass and try to
 1) Make it run on http hit or reload (maybe next step), Try to understand when 
the serviceClass constructor runs in order to get an idea about the lifecyle of 
your objects
 2) Locate where the logs go. This is always a non obvious step for me. But 
after that is downhill...
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
                 http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"; 
version="3.1">
  <display-name>MyCompany Services</display-name>
  <!-- <welcome-file-list> <welcome-file>Start.html</welcome-file> 
</welcome-file-list> -->
  <servlet>
    <display-name>MyCompany RESTful WS</display-name>
    <servlet-name>RESTFulCXFServlet</servlet-name>
    
<servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
  <-- Here you can extend the default servlet for logging or configuration purposes
    <init-param>
      <param-name>jaxrs.address</param-name>
      <param-value>
        /v1   <-- My Rest API is version 1
      </param-value>
    </init-param>
    <init-param>
      <param-name>jaxrs.serviceClasses</param-name>
      <param-value>
        com.mycompany.ws.impl.Service1,
        com.mycompany.ws.impl.Service2,
        com.mycompany.ws.impl.Service3,
        com.mycompany.ws.impl.Service4
      </param-value>
    </init-param>
    <init-param>
      <param-name>jaxrs.providers</param-name>
      <param-value>
        <!-- These may not needed -->
        com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider,
        com.mycompany.ws.impl.jaxrs.JacksonJsonParamConverterProvider,   <-- 
Special types Don't ask
        com.mycompany.lib.ws.cxf.jaxrs.RestServiceExceptionMapper,       <-- 
Handle exceptions
        com.mycompany.lib.ws.cxf.jaxrs.AcceptWildcardContainerRequestFilter, 
<-- Handle weird http requests
      </param-value>
    </init-param>
    <!-- registers extension mappings -->
    <init-param>
      <param-name>jaxrs.extensions</param-name>
      <param-value>
        xml=application/xml
        json=application/json
      </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>


  <!-- map it to the url: It would be /rest/v1/{endopoint} -->
  <servlet-mapping>
    <servlet-name>RESTFulCXFServlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>

  <!-- filter, listerner go below -->

</web-app>



On 2/10/22 18:53, Lewis John McGibbney wrote:
Hi Maxim,
Thanks for your response. See inline below

On 2022/02/10 03:11:59 Maxim Solodovnik wrote:
Hello Lewis,

cxf users@ list is very silent :)

Yes I see that!


what issues are you observing?

The real issue I am having is configuration without using Spring. I want to 
keep this as simple as possible. Just use JAX-RS + CXF. That's it! I was unable 
to find much documentation which indicated how that could be done.

The Nutch REST is currently run from the command line as a standalone service. 
I want to remove all that functionality by migrating it to a WAR which can be 
deployed into an environment like Tomcat, TomEE, Jetty, etc. so it is more 
stable, configurable and scalable.


While migrating our project I find out it is impossible to have "xml-free"
CXF :) (it was long time ago)
So we still have "cxf-servlet.xml" in our source tree: [1]
and it is referenced in web.xml [2]
everything seems to work as expected

[1]
https://github.com/apache/openmeetings/blob/master/openmeetings-web/src/main/webapp/WEB-INF/classes/cxf-servlet.xml
[2]
https://github.com/apache/openmeetings/blob/master/openmeetings-web/src/main/webapp/WEB-INF/web.xml

Thank you for these resources I will study them and try and implementation over 
the weekend. I'll write back here with my finding.
lewismc


--

Reply via email to