Domino & Spring Boot: How does it work

The example Spring Boot Plugin I have published two days ago is a full working example to run Spring Boot applications directly in the Domino HTTP task. It is designed as an OSGi plugin and runs inside the servlet container, which means that the „normal“ features of the Domino HTTP task are available at runtime, for example the existing the user session is accessible via the ContextInfo object.

To complile and deploy the plugin, you first have to install the XPages SDK and create the missing feature project and update site project as described in one of my older posts.
After importing the plugin in the UpdateSite and restarting the HTTP task, the Spring Boot application is ready and will flood the console with a lot of debugging informations when the first request hits the application:

While the example is a really basic one I am using the same approach for years in production environment. The reason is that it was fundamental for the customer (which has abandoned Domino years ago) to have a modern and industry-wide standard framework: The application is now a Spring Boot application which has a NoSQL backend – the decision makers had some buzzwords, the term „Domino“ is no longer used and all participants are happy now.

How does it work?

First it is required that the main configuration is still in the web.xml file. This is required because of the old servlet container which is still only available in version 2.5; I was not successfull to implement the latest Spring Boot version 5, because it seems that a servlet container version 3.0 is required.

In the web.xml file, the servlet mapping is defined:

<servlet>
   <servlet-name>dominoSpringBootServlet</servlet-name>
   <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
</servlet>

An additional configuration file dominoSpringBootServlet.xml contains the servlet specific configuration; both (the servlet name and the XML configuration) must have the same name, otherwise Spring Boot will not find the configuration file.

In this configuration file, the base package is defined, which tells the framework where to scan for Java classes and annotations:

<context:component-scan base-package="domino.springboot.plugin" />

The following line enables Spring Boot’s annotations:

<mvc:annotation-driven />

Now, the package domino.springboot is scanned for controllers and configuration classes, which I will describe in the next post.

 

Dieser Beitrag wurde unter Java, OSGi, Server, Spring, Web abgelegt und mit , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

3 Antworten zu Domino & Spring Boot: How does it work

  1. Hello Sven,

    Thanks for providing this information to the public. I was trying to use your examplary project with Domino SpringBoot plugin and could successfully import the bundle from within UpdateSite to OSGI environment within Domino Server. I am wondering, which version of Domino and underlying JVM do you use? I am working on Domino 9.0.1 and when I am trying to hit http://127.0.0.1/spring/greetings REST API endpoint I am receiving an error related to JVM versions mismatch:
    java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=javax/validation/constraints/NotNull, offset=6

  2. Baljit Kaur Karwal sagt:

    Hi,
    I am trying to create a REST API in domino. I am new to eclipse. Was always using designer but want to use eclipse to write API in Java.
    How do I import starter project from GitHub(such as Spring Boot Plugin) in UpdateSite?

    Thanks
    Baljit

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.