[[JAX-RS_Reference_Guide]]
= JAX-RS Reference Guide

This page outlines the three options you have for deploying JAX-RS
applications in WildFly {wildflyVersion}. These three methods are specified in the
JAX-RS 2.0 specification in section 2.3.2.

[[subclassing-javax.ws.rs.core.application-and-using-applicationpath]]
== Subclassing javax.ws.rs.core.Application and using @ApplicationPath

This is the easiest way and does not require any xml configuration.
Simply include a subclass of `javax.ws.rs.core.Application` in your
application, and annotate it with the path that you want your JAX-RS
classes to be available. For example:

[source, java]
----
@ApplicationPath("/mypath")
public class MyApplication extends Application {
}
----

This will make your JAX-RS resources available under `/`
`mywebappcontext` `/mypath`.

[WARNING]

Note that that the path is `/mypath` not `/mypath/*`

[[subclassing-javax.ws.rs.core.application-and-using-web.xml]]
== Subclassing javax.ws.rs.core.Application and using web.xml

If you do not wish to use `@ApplicationPath` but still need to subclass
`Application` you can set up the JAX-RS mapping in web.xml:

[source, java]
----
public class MyApplication extends Application {
}
----

[source, xml]
----
<servlet-mapping>
   <servlet-name>com.acme.MyApplication</servlet-name>
   <url-pattern>/hello/*</url-pattern>
</servlet-mapping>
----

This will make your JAX-RS resources available under `/`
`mywebappcontext` `/hello`.

[NOTE]

You can also use this approach to override an application path set with
the `@ApplicationPath` annotation.

[[using-web.xml]]
== Using web.xml

If you don't wan't to subclass `Application` you can set the JAX-RS
mapping in web.xml as follows:

[source, xml]
----
<servlet-mapping>
   <servlet-name>javax.ws.rs.core.Application</servlet-name>
   <url-pattern>/hello/*</url-pattern>
</servlet-mapping>
----

This will make your JAX-RS resources available under `/`
`mywebappcontext` `/hello`.

[NOTE]

Note that you only have to add the mapping, not the corresponding
servlet. The server is responsible for adding the corresponding servlet
automatically.
