WebEngine (JAX-RS)

Hello World

Updated: October 16, 2020

Module definition


<?xml version="1.0"?>

<module name="sample1" root-type="sample1" path="/sample1">

JAX-RS resources


import javax.ws.rs.*;
import javax.ws.rs.core.*;
import org.nuxeo.ecm.core.rest.*;
import org.nuxeo.ecm.webengine.model.*;
import org.nuxeo.ecm.webengine.model.impl.*;
import org.nuxeo.ecm.webengine.model.exceptions.*;
import org.nuxeo.ecm.webengine.*;

 * Web Module Main Resource Sample.
 * This demonstrates how to define the entry point for a WebEngine module.
 * The module entry point is a regular JAX-RS resource named 'Sample1' and with an additional @WebModule annotation.
 * This annotation is mainly used to specify the WebModule name. I will explain the rest of @WebModule attributes in the following samples.
 * A Web Module is implicitly defined by its entry point. You can also configure a Web Module using a module.xml file located
 * in the module root directory. This file can be used to define: root resources (as we've seen in the previous example), links, media type IDs
 * random extensions to other extension points; but also to define new Web Modules without an entry point.
 * A Web Module's Main resource is the entry point to the WebEngine model build over JAX-RS resources.
 * If you want to benefit of this model you should define such a module entry point rather than using plain JAX-RS resources.
 * This is a very simple module example, that prints the "Hello World!" message.
 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a>
public class Sample1 extends ModuleRoot {

  public String doGet() {
    return "Sample1: Hello World!";

  public String doGet(@PathParam("name") String name) {
    return "Sample1: Hello "+name+"!";


We'd love to hear your thoughts!

All fields required