Domino & REST: A basic Servlet

To have a good starting point when creating RESTful applications on top of Domino, I have created a „Hello World“ example of a JEE Application, based on Apache Wink & Jackson 2.5.0.

The Jackson AnnotaionProcessor is registered into Apache Wink application and is enabled by default, the JAXB processor is also included as the secondary AnnotationProcessor. The benefit of this is that only one global ObjectMapper instance is created and is reused, wich allows a better performance as when you create an own instance of an ObjectMapper for every request.

The servlet is deployed as a Plugin, so you need a working XPages plugin development environment first before you can build it (I won’t get in the details at this time). The code of the servlet can be found in the domino-rest-servlet.plugin project.

First have a look into plugin.xml: This file contains the extension point used by the plugin, which means that this tells the Domino server what is inside and what to do next with the plugin. The extension point is of type „“ and allows to run our own JEE application, independently of the XPages runtime. The contextRoot is the URI part on which our application „listens“. The contentLocation is where files are searched when accessed from the browser, and points to the WebContent folder (as you already know, it is the same as in XPages projects when using the package explorer view). Here you can store static files and/or resources if required.

The web.xml file is the servlet configuration and the place where the servlet is registered. With servlet-mappings you can define URI pathes *inside* of the JEE application.

In this example, every request is mapped to the RestServlet servlet when it is send to „http://your.server/dominorestservlet/„. It will be now processed by the class ch.hasselba.dominorestservlet.RestApiApplication, which „knows“ the RestApiServlet because of the @Path annotations.

Our „Hello World“ example is registered for the URI „/helloworld/“ and only for HTTP GET requests. As soon you are opening „http://your.server/dominorestservlet/helloworld/„, an instance of HelloWorld is created and transformed to JSON. The result looks like this:

{"message":"Hello World!"}

During the next blog posts, I will expand this example and explain step by step how a seamless integration in the Domino environment works.

You can find the code here:

Veröffentlicht unter Jackson, Java, JEE, REST, Web | Verschlagwortet mit , , , , , | 1 Kommentar

Domino & REST: Listeners for Initialization & Destroying of a Servlet

If you need to know when your Servlet is initialized or destroyed, you can use a ServletContextListener in your application.

First, create the class AppServletContextListener and implement the javax.servlet.ServletContextListener interface. This provides two methods for capturing the events: contextInitialized and contextDestroyed:

package ch.hasselba.servlet;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class AppServletContextListener
               implements ServletContextListener{

    public void contextDestroyed(ServletContextEvent event) {
        System.out.println("ServletContextListener destroyed");

    public void contextInitialized(ServletContextEvent event) {
        System.out.println("ServletContextListener started");

The ServletContextEvent allows you to access the ServletContext if required.

Now you have to register the listener in your web.xml:


As soon as you start or stop the HTTP task, the Listener is called, and you can execute some application specific code (i.e. shutdown threads, bring out the garbage, etc.)

Veröffentlicht unter Java, JEE, REST, Server | Verschlagwortet mit , , , , , | Hinterlasse einen Kommentar

Jackson: Skip Objects conditionally

I had a simple problem when implementing this brilliant solution in one of my REST applications: As soon I was using @JsonAnyGetter / @JsonAnySetter and the HidableSerializer together, a NPE was thrown during serialization. The Problem occured in Jackson 1.9.13 and even 2.5.0, the latest version usable with the actual Domino JVM.

  • Stack Trace (was java.lang.NullPointerException) (through reference chain: ch.hasselba.Test["[anySetter]"])
at ch.hasselba.HidableSerializer.serialize(
    at ch.hasselba.Demo.main(
Caused by: java.lang.NullPointerException
    ... 7 more

After hours of investigation, a simple solution came up on SO: The default serializer must be resolved, and then the code will work. I just had to override resolve method of my HidableSerializer:

public void resolve(SerializerProvider serializerProvider) throws JsonMappingException {
    if(defaultSerializer instanceof ResolvableSerializer) {

Here is a complete working example:


  • The Demo Code
package ch.hasselba;

import org.codehaus.jackson.Version;

public class Demo {

    public static void main(String[] args) {

        ObjectMapper mapper = new ObjectMapper();

        // register the module
        Version version = new Version(1, 0, 0, "SNAPSHOT");
        mapper.registerModule(new SimpleModule("HidableModule", version) {
            public void setupModule(SetupContext context) {
                context.addBeanSerializerModifier(new BeanSerializerModifier() {
                    public JsonSerializer<?> modifySerializer(SerializationConfig config, BasicBeanDescription desc,
                        JsonSerializer<?> serializer) {
                        if (IHidable.class.isAssignableFrom(desc.getBeanClass())) {
                            return new HidableSerializer<Object>((JsonSerializer<Object>) serializer);
                        return serializer;

        // the data
        String content = "{ \"foo\": \"bar\" }";

        // build the Object
        Test test = null;
        try {
            test =  mapper.readValue(content, Test.class);
        } catch (Exception e) {

        // and now convert it back to a String
        String data = null;
        try {
             data = mapper.writeValueAsString(test);
        } catch (Exception e) {

        System.out.println( data );




  • Test Class
package ch.hasselba;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.codehaus.jackson.annotate.JsonAnyGetter;
import org.codehaus.jackson.annotate.JsonAnySetter;

public class Test implements IHidable {

    private Map<String, Object> others = new ConcurrentHashMap<String, Object>();

    public Map<String, Object> getOthers() {
        return this.others;

    public void addOther(final String name, final Object value) {   
        this.others.put(name, value);

    public boolean isHidden() {
        return false;



  • Hideable Serializer
package ch.hasselba;


import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;

public class HidableSerializer<T> extends JsonSerializer<T>  implements ResolvableSerializer {

    private JsonSerializer<T> defaultSerializer;

    public HidableSerializer(JsonSerializer<T> serializer) {
        defaultSerializer = serializer;

    public void serialize(T value, JsonGenerator jgen, SerializerProvider provider)
            throws IOException, JsonProcessingException {

        if( value instanceof IHidable ){
            IHidable hidableValue = (IHidable) value;
            if( hidableValue.isHidden() )
        defaultSerializer.serialize(value, jgen, provider);

   public void resolve(SerializerProvider serializerProvider) throws JsonMappingException {
       if(defaultSerializer instanceof ResolvableSerializer) {


  • IHidable Interface
package ch.hasselba;

public interface IHidable {
    boolean isHidden();
Veröffentlicht unter Jackson, REST | Verschlagwortet mit , , , , | Hinterlasse einen Kommentar

Entwicklercamp 2017: Meine Vorträge & Hands-On

Dieses Jahr spreche ich wieder auf dem Entwicklercamp, und halte neben den Vorträgen auch noch eine Hands-On Session:

Im Laufe des Jahres 2016 kamen einige Themen hinzu, und dank FP8 wird es wohl auch einige Neuerungen geben, über die man mal reden müsste…

Hochperformante REST Schnittstellen entwickeln, die auf dem Domino Server laufen? Der Vortrag gibt Antworten auf die essentiellen Fragen des „Warum“ und des „Wieso“, und beleuchtet an praktischen Beispielen vor allem ausführlich die Frage des „Wie“.

Die praktische Umsetzung des Vortrages. Learning by doing.

Zur Anmeldung geht es hier entlang. Bis morgen (20.01.2017) gibt es auch noch den Frühbucherrabatt.

Veröffentlicht unter Allgemein, REST, XPages | Verschlagwortet mit , | Hinterlasse einen Kommentar

SNoUG 2017: Hochperformante REST Schnittstellen für Domino

Dieses Jahr spreche ich zum ersten Mal auf der SNoUG am 22. März diesen Jahres.

Wie der Name des Vortrages vermuten lässt, geht es um die Entwicklung hochperformanter REST Schnittstellen auf dem Domino Server, und der gesammelten Erfahrungen der letzten Jahre.

Es ehrt mich, auf diese kleine, aber feine Konferenz eingeladen worden zu sein, und ich freue mich auf weitere interessante Vorträge hochkarätiger Sprecher.

Zur Registrierung geht es hier entlang.

Veröffentlicht unter Allgemein, REST | Verschlagwortet mit , | Hinterlasse einen Kommentar

DomiNodeJS: Node.js on Domino

A while ago I started a new project which allows a seamless integration of Node.js into the Domino server.

The project is hosted on GitHub:

The Node.js server is running as a DOTS task, and under the hood the J2V8 project is used for the V8 integration.

Currently, the project is a pre alpha, and it it is more for fun than for profit. There are a lot of open questions about the architecture, but it shows what cool things can be done with Domino.

Veröffentlicht unter Allgemein | 4 Kommentare

Aus aktuellem Anlass: Quo vadis, Domino?

Schon mal darüber nachgedacht, was nach 2021 kommt? Migrationen dauern lange, sind niemals vollständig, und irgend ein wichtiges Detail wird übersehen. Und in der Zwischenzeit?

Gerne biete ich meine Unterstützung an: Bei der Suche nach Alternativen für IBM Notes / Domino, bei Strategien für den Übergang, oder bei der Kopplung an neue Systeme.

Einfach mal Kontakt aufnehmen. Gern auch per Mail: contact <at>

Veröffentlicht unter Allgemein | Hinterlasse einen Kommentar

Java NAPI: Enable / Disable Recycling of C Handles

Initialize Java NAPI "" );

Disable Recycling session, session, true );

Enable Recycling session, session, false );

To use these methods in an agent, you have to import some Jars first.

Veröffentlicht unter Java | Verschlagwortet mit | Hinterlasse einen Kommentar

XPages & Domino JNA

Karsten Lehmann has published a very promising project named „Domino JNA„, which allows access to the underlying IBM Domino/Notes C API from Java.

If you want to use the project in a XPages, you have to add some Java permissions to the java.pol file on your server:

grant {
    permission java.util.PropertyPermission "jnidispatch.path", "write";
    permission java.util.PropertyPermission "jna.loaded", "write";

Additionally, you have to import the following JARS from „domino-jna\target\lib“ (after a successfull Maven build) to a directory on the server (jvm/lib/ext) or import it into an NSF:

  • commons-collections4-4.0.jar
  • jna-4.2.2.jar
  • joda-time-2.9.2.jar
Veröffentlicht unter Java, Security, Server, XPages | 1 Kommentar

Vaadin In XPages: A UIComponent for embedding Vaadin applications

I have created an UIComponent to embed Vaadin applications into XPages. It allows to run both technologies on the same site by adding it to your XPage:

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

    <!-- XPages Application -->
        <xp:div id="refreshMe">
    <!--  VAADIN Application -->
        url = "/vaadin/"
        forceResize="true" />

This little example shows the XPage above including the the Adressbook application:

2016-05-03 12_31_17-VaadinInXPages

The Vaadin application is reachable at „http://localhost/vaadin/“ (hosted by Domino), that’s why the property url is set to „/vaadin/„. The property divId contains the name of the application which is used as id in the DOM tree.

It is required that the VaadinComponent is not inside a xp:form element. If it detects a surrounding form, a runtime exception is thrown. That’s why you have to set createForm to false and add your own xp:form to your application, as shown in the example.

2016-05-03 12_50_11-Runtime Error

If the parameter forceResize is set to true, a CSS style sheet is added to the XPage which resizes the height of html and the body node to 100%. Otherwise the Vaadin application will not be displayed correctly.

2016-05-03 12_54_35-view-source_localhost_VaadinInXPages.nsf_index.xsp

Resource Aggregation must be disabled, otherwise it won’t work.

The sources can be found at

Veröffentlicht unter Vaadin, XPages | Verschlagwortet mit , | 2 Kommentare