Press "Enter" to skip to content

Creating REST web services with Apache Wink on Tomcat

Wink is the JAX-RS implementation from Apache. I have never used it in a real-life project, but I thought it would be a good idea to create a small, dummy example as I did with RESTEasy and Jersey before just to see how easy/hard it is to get started with it.

First of all, let’s import the dependencies. We need to list wink-server in our pom.xml.

<?xml version="1.0" encoding="UTF-8"?>  
<project xmlns=""  





I am using the same RestExample class with the hello method that I have used in the previous examples with RESTEasy and Jersey.



public class RestExample {

    public String sayHello(@PathParam("name") String name){
        StringBuilder stringBuilder = new StringBuilder("SandBox | Hello ");

        return stringBuilder.toString();


In the case of Apache Wink we need to extend the class and override the getClasses method, which should return the set of classes that expose REST methods.

package net.gazsi.laszlo.sandbox.application;


import java.util.HashSet;  
import java.util.Set;

public class AppExample extends Application {

    public Set<Class<?>> getClasses() {
        Set<Class<?>> classes = new HashSet<Class<?>>();

        return classes;

The last step in setting up our REST endpoint with Apache Wink is to configure it in the web.xml

<?xml version="1.0" encoding="UTF-8"?>  
<web-app xmlns="" xmlns:xsi=""  
         xsi:schemaLocation="" version="3.0">
    <display-name>Laszlo Gazsi - Sandbox</display-name>



Finally, after deploying the application in Tomcat, making a GET request to http://localhost:8080/sandbox/rest/hello/Laszlo should result in the SandBox | Hello Laszlo! message.