Skip to end of metadata
Go to start of metadata

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

Subclassing and using @ApplicationPath

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

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

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

Subclassing 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:

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:

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.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Apr 20, 2013

    The annotation-only approach results in nothing but 404s for me.  There is nothing in the log, it is as if the annotation is not being recognized.

    The second two approaches both result in

    java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name

    This is on JBoss AS 7.1.1 Community edition.


    1. May 03, 2013

      I was having the same problem.  I finally realized that I had neglected to put the context (war file name) in the URL.  I stopped getting 404 errors when I annotated the Application with @ApplicationPath("restapp"), and used the URL http://localhost:8080/rest_example/restapp/MyRESTApplication.  The war file name was "rest_example.war".  


      I hope this helps someone.  I've been beating my head against the wall for a couple days.  

      Stuart, thanks for posting this article.  

      1. Jul 10, 2014

        Thanks Skip. Your solution helps me.

  2. Nov 12, 2015

    What happened to

    org.jboss.resteasy.plugins.spring.SpringContextLoaderListener in AS7?  Have these been deprecated?