Getting started

Tilen Faganel edited this page Mar 27, 2017 · 7 revisions

KumuluzEE allows you to quickly and efficiently bootstrap a Java EE application using just the components that you need so that your app remains light and fast. We will be using Maven to create a sample app.

Create the project

Let's create a new project.

$ mvn -B archetype:generate \
    -DarchetypeGroupId=org.apache.maven.archetypes \ \

Once created you must first add the appropriate dependencies. As mentioned the framework is completely modular which means that apart from the core functionality every component is packaged as a separate module and must be included explicitly as a dependency in order to use it. The framework will automatically detect which modules are included in the class path and bootstrap them together.

All modules are versioned and released together which helps us reduce cross version conflicts and bugs. So it is recommended to define a property with the current version of KumuluzEE and use it with every dependency. KumuluzEE ships with a BOM (bill of materials) in order to avoid version mismatches.

NOTE: Use the same version for every module as not doing so might result in unexpected behavior.


First include the BOM module which includes the definition of all modules.


Now we can start including the KumuluzEE dependencies. First include the core module.


Now the core itself won't do much without something to run. At the very least we have to include an HTTP server that will process our apps requests and of course process our servlets as they are the backbone of Java EE. We prefer to use Jetty as the servlet implementation for its high performance and small footprint. If however you prefer a different server (like Tomcat) you can easily do so provided it is supported. Now lets add Jetty.


This is the bare minimum required to run an app with plain servlets. Lets try it out! First we will add an simple servlet. We don't need to include a web.xml file as like application servers KumuluzEE supports annotation scanning. However when and if you need it you can simply add it and it will be automatically detected and used.


public class SimpleServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        response.getWriter().println("Simple servlet");

KumuluzEE will use a webapp folder at the root of your resources folder to look for files and configuration regarding it. This is the only difference to the standard Java EE file structure as the webapp folder has to be inside the resources folder, not alongside it.

Create a webapp folder at the root of your resources directory and add a sample index.html file to it.

<!DOCTYPE html>
    <meta charset="utf-8" />
    <title>Hello KumuluzEE</title>
    <p>Microservices with Java EE</p>

If you want to use the default settings this is all you need to do. The kumuluzee-core package provides the class with a main method that will bootstrap your app.

If you have your project opened in an IDE (IntelliJ, Eclipse, ..) you can now start the app by running the above class. If however you are looking to run it from the terminal (as will be the case on a server and various PaaS environments) then you run it directly from the class files in the target directory.

Run from the target directory

To run from the target directory you must include the maven-dependency-plugin to your pom.xml file which will copy all your dependencies together with your classes.


Run mvn install and then you can start your app using the following command:

$ java -cp target/classes:target/dependency/*

Note: In case of running Windows, use ";" instead of ":" character.

Go to http://localhost:8080/servlet in your browser and you should see "Simple servlet" written. You can also visit http://localhost:8080 to view the index.html that we've written.

Add the JAX-RS component to create REST services

To enable JAX-RS in your application add the apropriate dependency to your application and the framework will automatically detect and enable it.


And thats it. Lets now add an application.


public class RestApplication extends Application {


And a rest resource.


public class RestResource {

    public Response getResources() {
        Map<String, String> json = new HashMap<>();
        json.put("framework", "KumuluzEE");
        return Response.ok(json).build();

Run the app and visit http://localhost:8080/rest and you should see the following.

    "framework": "KumuluzEE"

Congratulations you have created a simple and lightweight Java EE app that follows the micro service pattern and can be easily deployed in a variety of cloud environments.

For a full blown tutorial, please read our blog post.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.