Use jersey 2.0 without maven

The most annoying thing recently for me is, I have to setup maven as a premise for using Jersey 2.0. The official document of Jersey does not provide enough information for me to setup Jersey without maven installed. After hours investigating and searching on the internet, I finally make it to work.

##Step 1: Prepare jersey jars First, you need to download all jars from the jersey site

Please download the Jersey JAX-RS 2.0 RI bundle version.

Now extract all the jars, copy them to your WebContent/WEB-INF/lib folder.

##Step 2: Setup jersey in web.xml

Open web.xml file under WebContent/WEB-INF/lib folder. If you don’t have the web.xml file, right click the project folder -> Java EE Tools -> Generate Deployment Descriptor Stub

In the web.xml, add following contents:

<display-name>Your Service</display-name>
    <servlet-name>Your Service</servlet-name>
    <servlet-name>Your Service</servlet-name>

IMPORTANT: The param-value inside servlet element MUST be exactly the same as the fully qualified name of the package contains jersey service classes. Otherwise a 404 not found error will be thrown at runtime.

Now deploy your web project, visit http://yourhost/yourproject/service/xxx to access the RESTful service.

That’s it.

Written on December 26, 2015