Show Table of Contents
3.2.5. JAX-RS and RESTEasy Changes
3.2.5.1. Configure JAX-RS and RESTEasy Changes
JBoss EAP 6 automatically sets up RESTEasy, so you do not need to configure it yourself. Therefore, you should remove all of the existing RESTEasy configuration from your
web.xml file and replace it with one of the following three options:
- Subclass
javax.ws.rs.core.Applicationand use the@ApplicationPathannotation.This is the easiest option and does not require any xml configuration. Simply subclassjavax.ws.rs.core.Applicationin your application and annotate it with the path where you want to make your JAX-RS classes available. For example:@ApplicationPath("/mypath") public class MyApplication extends Application { }In the above example, your JAX-RS resources are available in the path/MY_WEB_APP_CONTEXT/mypath/.Note
Note the path should be specified as/mypath, not/mypath/*. There should be no trailing forward-slash or asterisk. - Subclass
javax.ws.rs.core.Applicationand use theweb.xmlfile to set up the JAX-RS mapping.If you do not wish to use the@ApplicationPathannotation, you still need to subclassjavax.ws.rs.core.Application. You then set up the JAX-RS mapping in theweb.xmlfile. For example:public class MyApplication extends Application { }<servlet-mapping> <servlet-name>com.acme.MyApplication</servlet-name> <url-pattern>/hello/*</url-pattern> </servlet-mapping>
In the above example, your JAX-RS resources are available in the path/MY_WEB_APP_CONTEXT/hello.Note
You can also use this approach to override an application path that was set using the@ApplicationPathannotation. - Modify the
web.xmlfile.If you do not want to subclassApplication, you can set up the JAX-RS mapping in theweb.xmlfile as follows:<servlet-mapping> <servlet-name>javax.ws.rs.core.Application</servlet-name> <url-pattern>/hello/*</url-pattern> </servlet-mapping>
In the above example, your JAX-RS resources are available in the path/MY_WEB_APP_CONTEXT/hello.Note
When you choose this option, you only need to add the mapping. You do not need to add the corresponding servlet. The server is responsible for adding the corresponding servlet automatically.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.