Search code examples
javajax-rsopen-liberty

Openliberty Auto startup of JAX-RS beans


Any Open Liberty experts out here?

We are using OpenLiberty to boot our microservices in containers on OpenShift platform. The server will start up and initialize most of the application, but upon first call of an actual invocation of any endpoint, it starts initializing this corresponding bean. Database drivers are only then being loaded for example, and this will take the first HTTP call a long time to execute.

Is there any way to configure OpenLiberty in such a way that it will already initialize this pre emptively, during startup of the container?

I have tried two interesting looking properties:

The 'startEJBsAtAppStart' property here:

https://openliberty.io/docs/latest/reference/config/ejbContainer.html

And the 'deferServletLoad' property here:

https://openliberty.io/docs/23.0.0.8/reference/config/webContainer.html

But both did not change any behaviour I would expect.

Thanks in advance.


Solution

  • Currently, Open Liberty does not have a config option to preload JDBC drivers or create connections prior to the first request. (Though a feature has been proposed to do so https://github.com/OpenLiberty/open-liberty/issues/14900)

    If you want to pre-load your JDBC driver, and pre-warm your connection pool with connection(s) prior to the first request for consistent behavior you could look at writing it into your application as explained in this blog post: https://openliberty.io/blog/2020/09/09/pre-populating-db-connections.html