JBoss Community Archive (Read Only)

Latest WildFly Documentation

RS Reference Guide

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

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:

@ApplicationPath("/mypath")
public class MyApplication extends Application {
}

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

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

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:

public class MyApplication extends Application {
}
<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.

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

Using web.xml

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

<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 that you only have to add the mapping, not the corresponding servlet. The server is responsible for adding the corresponding servlet automatically.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 13:33:05 UTC, last content change 2013-12-19 00:12:36 UTC.