Giter VIP home page Giter VIP logo

openliberty-domino's Introduction

Domino Open Liberty Runtime

Inspired by Sven Hasselbach's blog posts, this project wraps Open Liberty, the open-source version of WebSphere Liberty, to run alongside the Domino HTTP task.

What It Does

Like the original blog posts, this provides access to Domino classes and the surrounding Domino server environment. At least in initial testing, unlike the blog posts, accessing databases on the server doesn't cause a panic, allowing this to run alongside normal Domino server operations.

What It Doesn't Do

This project does not enhance the Domino HTTP stack in any way. The traditional HTTP task continues as normal, with its same abilities and limitations.

Additionally, this doesn't give the Liberty server any particular knowledge of how Domino normally works - it won't serve resources from NSFs on its own, nor does it automatically have access to the XPages OSGi framework.

Requirements

  • Domino 9.0.1 FP10 or newer

Installation

The Open Liberty runtime can be installed either as a set of OSGi plugins running with Domino's HTTP runtime or using the RunJava command. In both cases, create a new database named libertyadmin.nsf in the root of your server using the provided NTF before loading the runtime.

OSGi Deployment

To install via OSGi, install the contents of the UpdateSite directory on your Domino server, either via an Update Site NSF or in the data directory.

RunJava Deployment

To install via RunJava, copy the JAR file from the RunJava directory into either the jvm/lib/ext directory or the ndext directory in your Domino installation. The runtime can be loaded by running load runjava WLP on the console or at startup adding runjava WLP to the ServerTasks notes.ini property. In these cases, "WLP" is case-sensitive.

Usage

After it is installed, open the admin NSF and add at least one server document. When HTTP is (re-)started on the server, servers configured here will be automatically deployed and launched. Additionally, if you create a "Dropin App" response document, you can attach .war files that will be automatically deposited in the "dropins" folder in the server. These applications can also be manually deployed there or added in the server.xml, as with a normal Open Liberty runtime.

Console Commands

The runtime supports several Domino console commands, all of which are prefixed by tell wlp:

  • status: Displays the status of all running Liberty servers. This is equivalent to the server status $name command in the Liberty package
  • stop: Stops all running Liberty servers
  • start: Starts all configured Liberty servers
  • restart: Equivalent to stop followed by start
  • help: Get a listing of currently-supported options
  • refresh: Refreshes the configuration from the NSF without restarting unchanged servers

Reverse Proxy

The installation contains a reverse proxy that can be enabled in the main configuration document of libertyadmin.nsf. In there, you can specify ports to listen on as well as a TLS private key and certificate chain, if desired. By default, the reverse proxy will relay all requests to the Domino server, while individual WAR apps deployed to Liberty servers can also be included via their documents. When they are marked as such, their context roots will be forward to them first, rather than to Domino.

Liberty Server Extensions

Deployed Liberty servers are installed with several custom features, which can be enabled per-server in the server configuration document in the NSF.

Notes Runtime

The notesRuntime-1.0 feature handles initialization and termination of the Notes runtime for the Liberty process, allowing individual web apps to skip this step and not compete. This feature sets the Java property notesruntime.init to "true" when enabled, so apps can check for that and skip process initialization.

Domino User Registry

This feature allows the use of Domino credentials for Liberty authentication, when applicable. It proxies authentication requests through to the backing Domino server specified by Domino_HTTP, and so it should allow any authentication that is configured on the Domino server. By default, Domino_HTTP is configured to be the local server, but it can be overridden in server.env.

Additionally, it allows for a shared login by proxying cookies containing Domino authentication information to the backing Domino server to determine the username.

This uses a servlet on the Domino side that responds to local requests only by default. To allow this service to respond to non-local requests, set the notes.ini property WLP_IdentityServlet_LocalOnly to 0.

Domino API Access

Code that uses the Notes runtime should take care to terminate all Notes-initialized threads, as leaving threads open may lead to server crashes. In practice, these steps have helped avoid trouble:

  • Ensure that any ExecutorService that contains Notes threads is shut down properly in a ServletContextListener
  • Run any Notes-based code in infrastructure listeners (such as ServletContextListeners) inside explicit NotesThreads and use Thread#join to wait for their results

Building

Building this project requires the presence of a p2 update site of the Domino XPages runtime. A version of this site matching Domino 9.0.1 is available from OpenNTF, and an updated version can be created from a Notes or Domino installation using the generate-domino-update-site tool. Put the file:// URL for this update site in the notes-platform property of your Maven configuration.

Additionally, to compile the Admin NSF via Maven and generate the final distribution, you will need to set up and configure a compilation server or local runtime using the NSF ODP Tooling project.

License

The code in the project is licensed under the Apache License 2.0. The runtime may download software licensed under compatible licenses - see NOTICE for details.

openliberty-domino's People

Contributors

dependabot[bot] avatar jesse-gallagher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

openliberty-domino's Issues

Look into SSO/login options

There are a couple routes to take here, to do with shared login with Domino and with generally authenticating against a Domino backend.

For shared login, Liberty can work with LTPA itself, but it may make even more sense to use the C API calls to stick with Domino's view of the world and not have to manually share the keys.
Things are less clear with non-SSO, however. As far as I can tell, Domino's session-based authentication isn't dealt with at all in the documented C API. One extremely-hacky route would be to include a user-info page in the proposed admin DB that the server could pass the cookie to to get the user, but that's pretty gross.

For authentication, it'd be worth investigating whether we can provide a standardized login module that authenticates against the Domino directory. I have an idea of how to do that per-app, but I'm not sure what the mechanism would be for adding that server-wide.

Add a mechanism for un-deploying WARs

Currently, there isn't a way to un-deploy WARs from in the Domino UI, and it'd be a tricky problem. Maybe, rather than trying to support document deletions, it'd be best to look into using the CLI API to un-deploy explicitly first. However, even that could have natural trouble, for example if the WAR file in a given app document changes.

Log file watching on Windows is extremely delayed

I suspect that this is just a limitation of Java NIO on Windows: I'm using the directory watcher mechanism, but it doesn't get immediate notifications and seems to only poll every couple of minutes. It may be best to switch to explicit quicker polling on Windows if possible.

Console output may not show up in the Domino log.nsf

This could be considered a blessing, since the console output is just a duplicate of the Liberty log files anyway, but it's at least odd. It's no doubt due to the NAPI method used to output the text with the "WLP: " prefix. Darwino doesn't have this trouble using a different API, so maybe there's an alternative that would work here.

Add DOTS fragment

Since the runtime isn't dependent on anything in the nHTTP environment specifically, it should work to add a DOTS contributor fragment alongside the org.openntf.openliberty.httpservice one to load the server when installed in DOTS.

Switch version scheme back to something traditional

Matching the version to the Liberty release is kind of nice, but those releases come out much more frequently than this needs to, and the way that this interacts with the runtime isn't liable to change much version-to-version.

Consider incorporating the XPages Runtime project

https://github.com/jesse-gallagher/xpages-runtime

Though the XPages and Notes artifacts themselves would certainly not be redistributable, it could be possible to write a feature bundle that assumes they'll be present and exposes the classes to apps, and then have the Domino runtime auto-vivify a fragment bundle with embedded dependencies during deployment.

In my initial investigation, I found that it was more trouble than it was worth to try to bring in the OSGi bundle versions of the XPages artifacts, so it'd make sense to pull together the various JARs into the fragment bundle instead of trying to include all the existing bundles.

Add ability to include SSL certificates for deployment

There are three ways I can see being useful:

  • .p12 file + password used directly
  • cert + key + chain files, auto-combined into a .p12 file with randomized password
  • Pulling from the server's active .kyr file (or a named one), converted with kyrtool

Improve proxy servlet's handling of credentials

The current proxy servlet doesn't quite work currently - it leads to a "Corrupted Content Error" when POSTing login credentials, which is a pretty big impediment. I'm not crazy about the proxy implementation, so it'd be worth doing another search for existing clean Java proxy implementations.

Originally posted by @jesse-gallagher in #4 (comment)

Investigate runjava or a C-based launcher

I should take another look at runjava some time: https://paulswithers.github.io/blog/2020/03/01/runjava . It doesn't have the full environment of DOTS or HTTP, but it would be controllable as a true task and, as Paul points out there, it's "supported enough" in that it's used by ISpy.

The main thing would be making sure the extensions work outside of an OSGi environment (which should be a matter of adding META-INF/services files) and then shading together an uber jar for it.

Investigate dynamically-configured external proxy

It could make sense to embrace the Liberty style of having one Liberty instance per application, and then put a proxy in front of all of the apps and Domino, dynamically configured based on names.nsf and the individual server.xml configurations.

The proxy servlet that I adapted in the repo already is okay, but I'm not terribly confident in it. It'd make more sense to find an existing standalone proxy server to use - I don't know if nginx would make sense here, but it'd certainly do the job.

Along with this, it would make sense to either always or optionally assign dynamic ports to the server.xml configs while writing them out to the filesystem.

Investigate running with external JVMs

It should probably work fine to spawn a separate JVM to run the container - it's really just a mild convenience to use the active one. In fact, it should be doable to automatically download and deploy an AdoptOpenJDK build.

One question, assuming it's possible, would be whether to auto-deploy Notes.jar in the JVM, or depend on the apps themselves. Though odd, it may be best to do the former, to avoid having to make the apps bundle a version-specific Notes.jar, just in case that changes.

Add proxy for legacy Domino HTTP requests

To make it so that this can "replace" the nHTTP stack as the entrypoint for HTTP in Domino, it could be worth adding an internal proxy for any unmatched URLs to pass through to Domino. Zuul may be a good option here. The route to do that may be to just add a default web app at the "/" context root that does the local proxying.

Investigate embedding API

Liberty ships with an embedding API: https://www.ibm.com/support/knowledgecenter/en/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_extend_embed.html

I've stayed away from this so far because it's good to have as distinct a runtime as possible to avoid causing trouble with nhttp. However, it could be that it'd provide some more-reliable control over the server, and it may be useful if the servers are ever initiated by an addin instead.

In early investigations, it's fiddly - it expects to find configuration files at locations relative to the com.ibm.ws.kernel.boot jar, making it awkward to embed inside a plugin. It seems like it's intended that you'd point at the WLP installation directory as the classpath for your running Java instance (or thread).

Improve handling of truncated log files

If, for example, a server is stopped and started externally to Domino, it can lead to an exception like this:

java.io.IOException: mark/reset not supported
 at java.io.InputStream.reset(InputStream.java:348)
 at org.openntf.openliberty.domino.runtime.OpenLibertyRuntime.lambda$watchLog$0(OpenLibertyRuntime.java:444)
 at org.openntf.openliberty.domino.runtime.OpenLibertyRuntime$$Lambda$18/0000000000000000.run(Unknown Source)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 at lotus.domino.NotesThread.run(Unknown Source)

It would probably make more sense in this case to instead close and re-open the input stream explicitly.

Crash observed when restarting HTTP after deploying an XPages WAR app

This showed up on the first HTTP request to the app after HTTP restart, after several messages, so it's not immediately on initializing Notes:

10908:000039-00007F419E1DA700] 06/08/2020 12:13:47 PM  WLP: [AUDIT   ] CWWKF0011I: The develop server is ready to run a smarter planet. The develop server started in 6.340 seconds.
[010908:000039-00007F419E1DA700] 06/08/2020 12:13:47 PM  WLP: [ODA] Starting the OpenNTF Domino API... Using notes.ini: /var/lib/domino/data/notes.ini
[010908:000039-00007F419E1DA700] 06/08/2020 12:13:47 PM  WLP: [ODA] OpenNTF API Version 0.0.0.unknown started
[010908:000039-00007F419E1DA700] 06/08/2020 12:13:47 PM  WLP: [err] Logging.logCfgFilePrecheck: File '/var/lib/domino/data/IBM_TECHNICAL_SUPPORT/org.openntf.domino.logging.logconfig.properties' not found
[010908:000039-00007F419E1DA700] 06/08/2020 12:13:47 PM  WLP: [err] Logging: Couldn't initialize from PropertyFile; activating fallback ...
[010908:000039-00007F419E1DA700] 06/08/2020 12:13:52 PM  WLP: [WARNING ] CLFAD0128W: The registry for the application 1 cannot depend on the library with id com.ibm.xsp.rcp.library, because there is no such library.


[006825:000129-00007F085BAF5700]  Thread=[006825:000129-00007F085BAF5700]
[006825:000129-00007F085BAF5700] Stack base=0x5BAF4FCC, Stack size = 21680 bytes
[006825:000129-00007F085BAF5700] PANIC: CheckTheProcesses - Process /opt/hcl/domino/notes/11000100/linux/jvm/bin/java (8044/0x1F6C) child of 0/0x0 has terminated abnormally

Auto-derive Domino HTTP settings for the environment

Currently, both the proxy app and TrustAssociationInterceptor look to the "DominoProxyServlet.targetUri" environment variable, which in turn is assumed to be added in server.env. When this is absent, it could be derived from checking the active server document's HTTP listen port and default hostname.

Investigating replacing reverse proxy servlet

Undertow looks like a likely candidate: https://undertow.io/undertow-docs/undertow-docs-1.3.0/index.html#introduction

It could make sense to run it in Domino's HTTP stack directly, since it will presumably open a separate port anyway, and will be more directly controllable without worrying about another distinct process. However, it could lead to trouble with Servlet versions: even if Undertow would be running its own HTTP endpoint, the javax.servlet v2.4/2.5 classes will almost definitely have to be exposed to its ClassLoader.

Java runtime deployment can't locate Java 14 OpenJ9 for Linux

[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Unable to find AdoptOpenJDK build for qualifier jdk_x64_linux
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at java.util.concurrent.FutureTask.report(FutureTask.java:133)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at java.util.concurrent.FutureTask.get(FutureTask.java:203)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at org.openntf.openliberty.domino.adminnsf.AdminNSFJavaRuntimeProvider.getJavaHome(AdminNSFJavaRuntimeProvider.java:183)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at org.openntf.openliberty.domino.runtime.OpenLibertyRuntime.run(OpenLibertyRuntime.java:110)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:522)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at java.util.concurrent.FutureTask.run(FutureTask.java:277)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at lotus.domino.NotesThread.run(Unknown Source)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP: Caused by: java.lang.IllegalStateException: Unable to find AdoptOpenJDK build for qualifier jdk_x64_linux
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at org.openntf.openliberty.domino.adminnsf.AdminNSFJavaRuntimeProvider.lambda$null$8(AdminNSFJavaRuntimeProvider.java:155)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at org.openntf.openliberty.domino.adminnsf.AdminNSFJavaRuntimeProvider$$Lambda$25.00000000C433CF70.get(Unknown Source)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at java.util.Optional.orElseThrow(Optional.java:301)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at org.openntf.openliberty.domino.adminnsf.AdminNSFJavaRuntimeProvider.lambda$getJavaHome$10(AdminNSFJavaRuntimeProvider.java:155)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  at org.openntf.openliberty.domino.adminnsf.AdminNSFJavaRuntimeProvider$$Lambda$8.00000000D001EF40.call(Unknown Source)
[022435:000010-00007FD92C5A1700] 05/05/2020 11:32:02 AM  WLP:  ... 4 more

Consider genericizing the tooling

There's nothing in this concept that ties it to Liberty specifically, so it could easily work to come up with a common management API (create server, deploy app, etc.) and make Liberty just one implementation of that.

However, I'm not sure it would be advantageous in reality to pick, say, GlassFish over Liberty for this purpose anyway, and Liberty is a logical and poetic choice for this job.

Updated dropin deployment doesn't work on Windows while running

This is because of how Windows file locking works. Liberty retains a lock on the file while it's running, and so it leads to NIO problems:

[0F10:0007-1360] 08/18/2019 04:57:38 PM  WLP: SEVERE Encountered exception when deploying dropin: java.nio.file.FileSystemException: C:\Domino\wlp\wlp-19.0.0.7\usr\servers\testServer\dropins\openliberty-domino-proxy.war: The process cannot access the file because it is being used by another process.

I'm not sure if there's a good way to fix this. Maybe use File#deleteOnExit on the old file and deploy with a unique name and hope that works. Slightly better could be to do that but also add a flag to delete the file when the runtime is issued a STOP command.

NoSuchFileException for logs on first run on Windows

[127C:00AD-0FF4] 03/03/2020 02:52:04 PM  WLP: java.nio.file.NoSuchFileException: D:\Domino\wlp\wlp-20.0.0.2\usr\servers\sftpServer\logs
[127C:00AD-0FF4] 03/03/2020 02:52:04 PM  WLP:  at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
[127C:00AD-0FF4] 03/03/2020 02:52:04 PM  WLP:  at sun.nio.fs.WindowsException.asIOException(WindowsException.java:106)
[127C:00AD-0FF4] 03/03/2020 02:52:04 PM  WLP:  at sun.nio.fs.WindowsWatchService$Poller.implRegister(WindowsWatchService.java:365)
[127C:00AD-0FF4] 03/03/2020 02:52:04 PM  WLP:  at sun.nio.fs.AbstractPoller.processRequests(AbstractPoller.java:260)
[127C:00AD-0FF4] 03/03/2020 02:52:04 PM  WLP:  at sun.nio.fs.WindowsWatchService$Poller.run(WindowsWatchService.java:595)
[127C:00AD-0FF4] 03/03/2020 02:52:04 PM  WLP:  at java.lang.Thread.run(Thread.java:819)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.