REST Services in GateIn / eXoPlatform : add your own !

Mulitple REST services are available out of the box in GateIn / eXoPlatform. They allow to easily interact with the platform’s features and data.

Here we will see how to quickly add your own REST services (valid for eXoPlatform 3.0 or 3.5).

Java REST class

Firstly, we create the Java class which will expose the REST service :




public class MyRESTService implements ResourceContainer {

    public Response getName(@PathParam("name") String name) throws Exception {
        return Response.ok("Hello " + name + " !").build();


As you can see, this class uses standard JAX-RS annotations to expose its services (*). The only thing to add is the interface. This interface is a marker to define this class as a REST services class.

If you use Maven, the class is available with the following dependency :


Adjust the dependency version according to your Gatein / eXoPlatform version.

Declare your REST service

The second and last thing to do is to declare the REST service. To achieve this, declare your class in the GateIn / eXoPlatform configuration :


This configuration can be put either in the jar containing the java class (in conf/portal/configuration.xml), or in an extension, or even in the external configuration.

Now you just have to deploy your class and your configuration (for example, put the jar containing the class and the configuration in the tomcat’s libs), and restart the server.
Your service is now available at http://<host&gt;:<port>/portal/rest/user/name/<yourname> :

Up to you now to implement your custom REST service !

  1. #1 by Mallikarjun Ps on 27/09/2013 - 17:04

    thank you for the post. I am building a custom rest service in exo platform and my service dependent on some third party jars. instead of copying these jars manually into tomcat lib folder , is there a I can ship them along with my service. I created a extension project with war containing these libraries but for some reason these jars are not recognized buy exo while running my services and throwing ClassDefNotFound error.


  1. eXo Blog – The Cloud User Experience Platform – Boost your eXo Platform Development with JRebel!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: