Deploying Jersey to JBOSS

I spent the afternoon playing around with Jersey in JBOSS. Jersey is a Java API for publishing REST web-services, and JBOSS is the application server we use at work. Not finding any particularly helpful tutorials, I muddled my way through. Lucky for you, I have distilled the required steps here.

The first step is to create a Java class with the method you would like to invoke via a REST call. Here is what I came up with:

package com.bitkickers;

import java.util.Map;

public class JerseyServices {

 public String helloWorld(@QueryParam("name") String name) {
  return String.format("Hello, %s", name);

The annotations include @Path("JerseyServices"), which defines a path relative to the web context to serve all of the methods in this class from. @GET, tells Jersey to attach to HTTP GET requests for this method. @Path("/helloWorld") and @QueryParam("name") combine to define the whole relative URL as "/JerseyServices/helloWorld?name=Chase" to call this method with the parameter name set to "Chase".

The web.xml to tie in the Jersey servlet looks like the following:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns=""

    <display-name>Jersey API Skunkworks</display-name>




The parameter "" tells "ServletContainer" to scan for any classes annotated with @Path in the package "com.bitkickers", recursively. The servlet mapping tells the servlet to attach to the URL "/api".

Finally, the jboss-web.xml just sets the root context to "jersey":

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN" "">


All together, the URL to invoke this REST call becomes "http://localhost:8080/jersey/api/JerseyServices/helloWorld?name=Chase".

Also included in the download is an ANT file to build the WAR, and an HTML file that uses jQuery to invoke the REST service.

I'm currently working at NerdWallet, a startup in San Francisco trying to bring clarity to all of life's financial decisions. We're hiring like crazy. Hit me up on Twitter, I would love to talk.

Follow @chase_seibert on Twitter