[[JAXRS]]
== JAXRS Subsystem Configuration

The `jaxrs` subsystem represents https://projects.eclipse.org/projects/ee4j.jaxrs[Jakarta RESTful Web Services].
https://resteasy.github.io[RESTEasy] is the implementation.

=== Required Extension:

The required extension is in the module `org.jboss.as.jaxrs`. In most cases the extension should be present. However, if it
is not you can add it with CLI.

[source]
----
/extension=org.jboss.as.jaxrs:add
----

This adds the following configuration entry:

[source,xml,options="nowrap"]
----
<extension module="org.jboss.as.jaxrs"/>
----

=== Basic Subsystem Configuration Example:

By default the `jaxrs` subsystem is empty which results in default configuration values being used.

This can be changed with a management client such as the CLI or the web console. You can get detailed information about the
"Configuration switches" in section 3.5 of the https://resteasy.dev/docs[RESTEasy User Guide].

An example configuring the subsystem with the CLI:

[source]
----
/subsystem=jaxrs:write-attribute(name=resteasy-add-charset, value=true)
/subsystem=jaxrs:write-attribute(name=resteasy-gzip-max-input, value=17)
/subsystem=jaxrs:write-attribute(name=resteasy-gzip-max-input, value=17)
/subsystem=jaxrs:write-attribute(name=resteasy-jndi-resources, value=["java:global/jaxrsnoap/EJB_Resource1", "java:global/jaxrsnoap/EJB_Resource2"])
/subsystem=jaxrs:write-attribute(name=resteasy-language-mappings, value={"es"="es", "fr"="fr", "en"="en-US"})
/subsystem=jaxrs:write-attribute(name=resteasy-media-type-param-mapping, value=mt)
/subsystem=jaxrs:write-attribute(name=resteasy-providers, value=["com.bluemonkey.reader", "com.bluemonkey.writer"])
----

This generates the following XML configuration.

[source,xml,options="nowrap"]
----
<subsystem xmlns="urn:jboss:domain:jaxrs:2.0">
    <resteasy-add-charset>true</resteasy-add-charset>
    <resteasy-gzip-max-input>17</resteasy-gzip-max-input>
    <resteasy-jndi-resources>
        <jndi>
            java:global/jaxrsnoap/EJB_Resource1
        </jndi>
        <jndi>
            java:global/jaxrsnoap/EJB_Resource2
        </jndi>
    </resteasy-jndi-resources>
    <resteasy-language-mappings>
        <entry key="es">
            es
        </entry>
        <entry key="fr">
            fr
        </entry>
        <entry key="en">
            en-US
        </entry>
    </resteasy-language-mappings>
    <resteasy-media-type-param-mapping>mt</resteasy-media-type-param-mapping>
    <resteasy-providers>
        <class>
            com.bluemonkey.reader
        </class>
        <class>
            com.bluemonkey.writer
        </class>
    </resteasy-providers>
</subsystem>
----

[NOTE]
====
The use of hyphens is a WildFly convention. The hyphens are translated into periods before
the parameters are passed into RESTEasy so that they conform to the RESTEasy parameter names.

For a discussion of the various parameters, see the RESTEasy User Guide.
====

IMPORTANT: One important thing to understand is that these parameters are global. That is, they  apply to all deployments.
Since these parameters are global, the classes referred to in "resteasy.providers" and "resteasy.disable.providers"
must be available to all deployments. In practice, then, they are meant to enable
or disable RESTEasy providers. Note that they can be used in conjunction with
"resteasy-use-builtin-providers" to tailor a set of available providers.

IMPORTANT: Another important fact is that once parameters are changed via some management interface the changes require
           a redeployment of any applications previously deployed.

IMPORTANT: RESTEasy has introduced a new treatment of `jakarta.ws.rs.WebApplicationException`&apos;s thrown by a
Jakarta REST client or MicroProfile REST Client running inside a RESTful resource, in which the embedded
`jakarta.ws.rs.core.Response` is "sanitized" before being returned to prevent the risk of information leaking from a
third party. The original behavior can be restored by setting the parameter
"resteasy.original.webapplicationexception.behavior" to "true". See the https://resteasy.dev/docs[RESTEasy User Guide]
chapter "Resteasy WebApplicationExceptions" for more information.
