0

I am trying to build using JAXRS-1.1 feature along with servlet-3.1 and transportSecurity-1.0 I am having a hard time with the set up.

If I do not include JAXRS-1.1, I still see many errors when making simple PUT calls to the server such as

[INFO] (org.codehaus.mojo.pluginsupport.ant.AntHelper) org.apache.cxf.interceptor.Fault
[INFO] (org.codehaus.mojo.pluginsupport.ant.AntHelper) [WARNING ] Exception in handleFault on interceptor org.apache.cxf.jaxrs.interceptor.JAXRSDefaultFaultOutInterceptor@ccb42500

and this makes me think JAXRS comes embedded.

I have not been able to figure out how to check if OpenLiberty comes embedded with JAXRS-2.0

Here is the server.xml

<server description="Sample Servlet server">
    <featureManager>
        
        <!-- https://openliberty.io/docs/latest/reference/feature/microProfile-1.0.html -->
        
        <feature>servlet-3.1</feature>
        <feature>transportSecurity-1.0</feature>    
    </featureManager>

    <variable name="default.https.port" defaultValue="9443" />
    <variable name="app.context.root" defaultValue="ServletSample" />
    <variable name="keystore.path" defaultValue="${WLP_OUTPUT_DIR}/resources/security/key.p12" />

    <!-- tag::httpEndpoint[] -->
    <httpEndpoint httpPort="-1" httpsPort="${default.https.port}" id="defaultHttpEndpoint" host="*" />
    <!-- end::httpEndpoint[] -->

    <webApplication location="ServletSample.war" contextRoot="/" />

    <keyStore id="defaultKeyStore" password="${env.GARBLED_KEYSTORE}" />
    <ssl id="defaultSSLConfig" keyStoreRef="defaultKeyStore" trustStoreRef="defaultKeyStore" clientAuthenticationSupported="true" sslProtocol="TLSv1.2" />
    <ssl id="controllerConnectionConfig" keyStoreRef="defaultKeyStore" trustStoreRef="defaultKeyStore" sslProtocol="TLSv1.2" />
    <ssl id="memberConnectionConfig" keyStoreRef="defaultKeyStore" trustStoreRef="defaultKeyStore" sslProtocol="TLSv1.2" />

</server>

and since it is a requirement to build with JAXRS-1.1, I have simply added that as a dependency in maven. Maven's pom.xml dependency section look like this:

<dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.1.1</version>
        </dependency>
</dependencies>
  • What's in your feature list? When you enable servlet-3.1, it enables jaxrs-1.1 and jaxrs-2.0 (see https://www.ibm.com/docs/en/was-liberty/base?topic=features-java-servlets-31) – F Rowe Mar 07 '23 at 21:38
  • @FRowe it it the other way around - jaxrs enables servlets (not servlets jaxrs), as one may just use servlets without rest services. There is no embedded JAXRS, but maybe you are using default config which enables some features (eg webprofile) – Gas Mar 08 '23 at 15:17
  • @Uzair add your `server.xml` to the question. If you want to use rest you need to add jaxrs feature. – Gas Mar 08 '23 at 15:19
  • updated with server.xml file. @Gas – Uzair Hassan Mar 08 '23 at 18:31
  • @Uzair I can see why the error messages caused you to ask the question wondering if there was "embedded JAXRS" (though is that message coming from the server?). But in any case, the feature set exposed to applications is carefully documented in the Open Liberty docs. Sometimes one feature enables another, e.g. `jaxrs-2.0` enables `servlet-3.1`: https://openliberty.io/docs/latest/reference/feature/jaxrs-2.0.html#_features_that_this_feature_enables, and as I noted in a comment in the answer, EE 6 -level features like jaxrs-1.1 are only available in WebSphere Liberty not Open Liberty. – Scott Kurz Mar 09 '23 at 18:08
  • Even if the Liberty server were to use some JAX-RS function internally without a JAX-RS feature being enabled, it would not be carefully guarded and not accessible for application use, without the appropriate features being enabled (in server.xml, etc.) – Scott Kurz Mar 09 '23 at 18:09

1 Answers1

3

When Liberty was first build, they made a concious decision to only support the more current standards. They didn't want to get bogged down with old and obsolete specifications.

So, as I understand it, OpenLiberty only supports JaxRS 2.0 and above, so the answer is no.

See:

Bill Mair
  • 1,073
  • 6
  • 15
  • Yes, the EE 6 features such as jaxrs-1.1 are available in WebSphere Liberty, but Open Liberty only supports EE 7 and above (generally speaking). – Scott Kurz Mar 09 '23 at 18:00